Refactored assertErrorResponse.