Why would mussels be gritty? I've made my first attempt at cooking moules frites however I'm a bit disappointed with the results.

The batch of mussels were purchased from an online fishmonger specialising in Cornish seafood in the UK. Two thirds of the batch had already opened so following advice online I discarded them. The remaining ones I thoroughly washed in cold running water and removed any beards visible. On cooking, they all opened however they all tasted gritty and in the shells I could see black sludge. 

Have I done something wrong? Is there an additional preparation step I missed? Or is it a bad batch?

Any help or advice is much appreciated. I haven't cooked fresh mussels before so it's a bit of a learning experience for me!
With regards to the grit, if they aren't farmed mussels (which generally are fairly clean) you may want to give them a soak for a while. This will give them the chance to expel any further sand/grid they may contain. There are varying theories of whether to use tap water, salt water, sea water or various other concoctions. And admittedly there are those who say any form of soaking will do all sorts of harm to the flavour. But if the alternative is disappointing gritty mussels, why not give it a try. 

And as always, ask your fishmonger for advice. They will know the origin of the product, and whether or not you need to take extra steps in preparing them. 

As for discarding opened mussels, don't just discard them when they seem open on arrival. If the shell is not cracked, give them a light tap (on the counter or with a knife) and see whether or not they will close in response. If they close in response, they are fine. If they don't close or tell you to stop it, then discard them. 

And if two thirds of the batch really are dead ... I personally would not necessarily trust the other third to be in great shape.