refactored unit testing