refactoring unit testing and passing