Refactor test code.