refactoring unit testing