Refactoring of services and adding unit tests