refactor unit test code