Refactoring test code