Refactors the test code.