One of the reasons your mind wandered off is because you were reading too slow. The mind can think at 500 words per minute and regular reading is generally too slow. So read faster is one way.
The other thing you could have done to improve your focus is use the tangerine technique. This has been found to help many keep their focus on the task before them
Third thing you should have done is some quick mental maths. Note the total time allowed for the test and divide that by the number of questions you have to answer. Eg 60 minutes for the test 28 questions so divide 60 by 30 that means you have about 2 minutes per answer. Knowing this with your watch on the table you notice when you should be starting the next question. It stops the mind from wandering off thinking it has all the time in the world. Notice I rounded the number up. This buys you a little time to go back to any questions that you had to leave unanswered. Also to be sure that I have time left over I'd be pushing to get the answers in 90 seconds and moving on to the next question ASAP. That way I'd leave 10 to 15 minute to go back over those tricky questions. As well as that a timer is a great way to keep focus so go into a test with a watch with a second hand and do keep an eye on it. Place it on the table where you can quickly see it if you cannot place it on your wrist in a fasion that allows you to quickly glance at it.
An interesting thing too often the first answer that jumps into the mind is correct by having a deadline you prevent yourself from analysing it to death (literally) only to pick the wrong answer.
Be prepared. Another way to have focus during the test.
Alex