improve error handling and add service tests