Glad you found that helpful.
Yes, I believe you are right about test 4. I do not have much experience with righting java questions and did not think of that. Often our question types have extra parameters that allow us to ban the use of certain functions or strings in the students code. So with that sort of approach you could ban the use of the funciton 'correct_answer' by the student. Although I do not currently have a java question type that implements this behavior.
I intentionally didn't use correct_answer in test case 5 because I wanted to show it as an entirely separate approach. If you did not use test case 4 then there would not really be the need. I would only use global extra if there is code that needs to be shared across multiple test cases and as you point out there is a risk that the student could discover and use it (although unlikely if they can't see the function names).
Another thing that I'm sure what be possible would be to restructure the template code so that the tests are run in a separate class. That way the functions defined in global extra could be defined to be private and only callable by the test code and not the students code.