Refactoring a test