Hey guys

So, for about 5 1/2 years I have been training at a respectable dojo in Goju ryu karate and a little bit of kenpo. Right now, I'm a blue belt with three stripes, so almost brown! Anyway, my friends all know about my training, and some of them throw punches(fake, no contact) toward me to see what I do. When this happens, however, I sometimes miss the punch, or do something silly that I know I shouldn't be doing to defend myself. When I'm in the dojo, my self defence techniques and sparring skills are fairly adequate. Why is it when I am tested outside my dojo I fail? Granted, they are half assed punches being thrown at me, no real effort, but still. How can I fix this? I vowed only to use my skills to defend myself or others, so I want to make sure I'm properly prepared for it if need be. Tips? Strategies? I'm 16 by the way.