its nice to see I'm not alone in having that cough/bolt instinct.
Darwin sees to it that all humans have that reaction - those who don't have it have not normally survived very long in water
+1 for practice, practice, practice etc. the muscle memory really will be learned and will be there for you when you need it -
I really hate
the thought of taking my mask off under water, although I don't actually have any problem doing it, or clearing the mask, or even swimming with a flooded mask or no mask, and I never have had a problem or bad experience with this skill, but if I know I have to remove my mask for an exercise on a course the thought of doing it really makes me extremely uncomfortable, so much so I will think of excuses not to do it and try to avoid doing it.
When I did my CMAS 3 Star on one of the test dives an instructor had dropped in behind me unseen, he switched off my tank valve then pulled my mask off and dislodged my regulator - this was in about 45' of water. I automatically took my octopus, only got half a breath, I knew how much air I still had so loosened my bcd and reached the valve to switch it back on, when I was comfortably breathing again it was at this point that I realised I had no mask on. The instructor had it in his hand - he gave it back when I asked for it with an appropriate hand gesture (well he got my meaning).
My point is that I didn't really think about any of it, I couldn't see where my primary had gone but knew where my octopus was so went straight to it, I knew I had air left so correctly guessed my tank valved had been rolled off and dealt with that, the absence of the mask didn't even figure until I had sorted the regulator and air out, and both actions to do this were so instinctive my buddy, who was ready with his octopus, didn't even get time to deploy it.
So practice, practice, practice and when it happens for real you will often find you have instinctively sorted things out before you have time to think about what has gone wrong, and on those rare occasions when you haven't you will have the confidence to take those few seconds to work out what is going wrong and how to sort it.
Finally practice your buddy diving - you are not down there alone ! - a good buddy who is attentive to what is going on in the buddy pair and during the dive will always be there to step in, support you and help you out if you can't sort your problems yourself.
I know my example might seem a bit extreme, but the Russian dive club I learned with still rather macho, it still teaches buddy breathing in a group off one regulator, teaches emergency rebreathing from your BCD and does all of its courses from basic OW through to instructor in the open sea from dive 1. It would not survive in the PADI or BSAC world of standards and health and safety, and I do not endorse or promote the way it teaches, but that experience has stayed with me and gives me a lot of confidence that I have a fair idea how I will react when it happens for real.
Dive safe and don't beat yourself up, you now know what it feels like, and you know the answer - practice, practice, practice and you will learn not to be frightened into bolting - Phil.