refactoring services and unit testing