refactoring to improve unit testing