             }
         #endif
 
-        let failure = { (error: Error) in
-            if error.localizedDescription.contains("does not permit customization") {
-                expectation.fulfill()
-            } else {
-                XCTFail(error.localizedDescription)
-
-            }
-        }
-
-        languageTranslator.createModel(
-            baseModelID: "en-es",
-            name: "custom-english-to-spanish-model",
-            forcedGlossary: glossary,
-            failure: failure)
-        {
-            model in
+        languageTranslator.createModel(baseModelID: "en-es", name: "custom-english-to-spanish-model", forcedGlossary: glossary) {
+            response, error in
+
+            if let error = error {
+                if error.localizedDescription.contains("does not permit customization") {
+                    expectation.fulfill()
+                    return
+                } else {
+                    XCTFail("Unexpected error response from service: \(error)")
+                    return
+                }
+            }
+            guard let model = response?.result else {
+                XCTFail("Missing response value")
+                return
+            }
+
             XCTAssertNotEqual(model.modelID, "")
-            self.languageTranslator.deleteModel(modelID: model.modelID, failure: self.failWithError) { _ in
+            self.languageTranslator.deleteModel(modelID: model.modelID) {
+                _, error in
+
+                if let error = error {
+                    XCTFail("Unexpected error response from service: \(error)")
+                }
                 expectation.fulfill()
             }
         }

    func testTranslateStringWithModelID() {
        let expectation = self.expectation(description: "Translate text string using model id.")
        let request = TranslateRequest(text: ["Hello"], modelID: "en-es")
        languageTranslator.translate(request: request, failure: failWithError) {
            translation in
            XCTAssertEqual(translation.wordCount, 1)
            XCTAssertEqual(translation.characterCount, 5)
            XCTAssertEqual(translation.translations.count, 1)


    func testListModelsBySourceLanguage() {
        let expectation = self.expectation(description: "List models, filtered by source language.")
        languageTranslator.listModels(source: "es") {
            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()
        }
