Update service tests and optimizations to code for testing purposes