You seem to have test anxiety which is a fairly common thing. Talk with your mom/dad, a teacher you trust, or your school counselor, and tell them the problem you're having. Sometimes kids with test anxiety are given special accommodations that allow to take tests in a setting that creates less anxiety for them, and perhaps have extra time to complete the test so there's less stress. Best wishes!
Being well prepared has its advantages. It can boost your confidence and help cancel out the anxiety. As for the bathroom, make sure not to drink liquids before the test. I'm sure if it's an emergency you will be permitted to use the bath room. Practice deep breathing. Learn meditation. This will also help. Good luck. Maxy