Added tests and error throwing to services