First, about the temperature. Your safest option is to use a gun ;) The correct temp for shallow frying is between 150 and 190 degrees celsius. So if you have an infrared "gun" (a thermometer which neasures the temp of the surface at which it is pointed), use it to determine the stove setting at which the temperature of the dry (not ptfe coated) pan stabilizes in this interval after longer heating. If you don't have it, use the typical tricks for determining the pan temp, they are described in other questions here on SA.
Important: different stoves heat to different temperatures. Don't let the numbers at the knob to fool it into thinking that a given temp is "medium high" because it has the number 7. My own stove stabilizes at ~180 degrees C at setting 2 (out of 10), with setting 3 pushing 230. On the other hand, the minimum temperature for cooking fish is 50 deg. As stoves rarely go below 80 degrees, there is practically no chance to set your stove to a temperature so low that the fish stays undercooked (but it might need unreasonably long times on very low settings).
As for the spraying: the fat at frying temperature will always spray. You can still reduce your problems. First, the bubble explosions at the lower temperature will be less violent. Second, surface moisture promotes spraying (which is produced by water being instantly turned into steam in the oil). So pat the fish dry with paper before frying it. If this isn't enough, you can also drag it through flour. This will make the crust crisper. As the spraying won't be eliminated completely, don't throw in the pieces. Take a flat spatula with a long handle, place the piece on the working end, step back from the stove and slowly lay the fish into the oil, gradually pulling the spatula from beneath it. The turning should produce less spraying, so using a fork or spoon to press the fish against the spatula isn't a problem (or kitchen pincers, if you have those).
All of the above applies to everything you are shallow frying, not only fish. Only the flour is unsuitable for some vegetables.
I am wondering if it will be ok to cook them till they are cooked and then drain them, clean them and put them in some fresh water with some garlic and butter to cook again...
Yes that should be fine, just make sure you discard any shells that have not opened by the end of cooking as those are dead ones.
Here's a nice recipe for moules marinières, mussels cooked with butter, white wine, shallots, cream and herbs which also explains how to de-beard them.
Best Answer
I'm familiar with the preparation of what the Portuguese call Amêijoa and Berbigão (the former being a clam, the later a cockle).
A general advice upfront: make sure that cockles in your region at this season are safe to eat as shellfish tend to accumulate potential harmful substances in their tissue.
Cleaning with seawater
I (or already the fishermen that collected the cockles) usually put them in a container with seawater which was changed every five or six hours. The more often you repeat this procedure the less sand you'll have in your meal (however, even in restaurants it is not uncommon to find a bit of sand). You don't want to keep them in there longer than a day though. Keep them out of direct sunlight. Refrigeration generally is not necessary for half a day to a day. Afterwards discard all individuals that are open (= dead) and use the remaining cockles to prepare your meal.
Cleaning with freshwater
I have never put them into freshwater, therefore here only a guess: theoretically you can simulate seawater by adding the right amount of salt. You'll miss all other elements though, including nutrition, and therefore will generate stress for the cockles which will likely impede their ability to filter water (= clean) and survive. I advice you to use seawater if you have access.
A recipe
A Portuguese recipe includes white wine, a fair amount of garlic, parsley and olive oil. Heat the olive oil in a pot, cut the garlic in half or quarters (not too small) and add them to the pot. Once they are precooked add the cockles and the white wine. Put a lid. Once the cockles are open they are ready to eat (some will not open - Discard closed cockles). Add the parsley when nearly all the cockles are open and cook for a minute more. Eat them straight out of the shell, maybe with a bit of lemon juice. Use bread to enjoy the cooked white wine mixture. Eat the garlic, it should taste delicious.