Services Unit tests and refactoring