added error endpoints and tests