added unit test for services and optimized for server