 
     func testListModelsByTargetLanguage() {
         let expectation = self.expectation(description: "List models, filtered by target language.")
-        languageTranslator.listModels(target: "pt", failure: failWithError) { models in
+        languageTranslator.listModels(target: "pt") {
+            response, error in
+
+            if let error = error {
+                XCTFail("Unexpected error response from service: \(error)")
+                return
+            }
+            guard let models = response?.result else {
+                XCTFail("Missing response value")
+                return
+            }
+
             XCTAssertGreaterThan(models.models.count, 0)
             expectation.fulfill()
         }

    func deleteStaleCustomModels() {
        let description = "Delete any stale custom models previously created by unit tests."
        let expectation = self.expectation(description: description)
        languageTranslator.listModels(defaultModels: false, failure: failWithError) { models in
            for model in models.models where model.baseModelID != "" {
                self.languageTranslator.deleteModel(modelID: model.modelID, failure: self.failWithError) { _ in }
            }
            expectation.fulfill()
        }
        waitForExpectations()
    }

    /** Fail false negatives. */
    func failWithError(error: Error) {
        XCTFail("Positive test failed with error: \(error)")
    }

    /** Fail false positives. */
    func failWithResult<T>(result: T) {
        XCTFail("Negative test returned a result.")
    }

    /** Fail false positives. */
    func failWithResult() {
        XCTFail("Negative test returned a result.")
    }

    /** Wait for expectations. */

    func testTranslateStringWithSourceAndTarget() {
        let expectation = self.expectation(description: "Translate text string using source and target.")
        let request = TranslateRequest(text: ["Hello"], source: "en", target: "es")
        languageTranslator.translate(request: request) {
            response, error in

            if let error = error {
                XCTFail("Unexpected error response from service: \(error)")
                return
            }
            guard let translation = response?.result else {
                XCTFail("Missing response value")
                return
            }

            XCTAssertEqual(translation.wordCount, 1)
            XCTAssertEqual(translation.characterCount, 5)
            XCTAssertEqual(translation.translations.count, 1)
