refactor test code