Set the status code 404 for not found and fix tests