refactor some test code