improve JAX-RS error handling and fix unit test