Added unit tests and improved exceptions thrown by service