Fix raising and testing of error on invalid JSON in response.