                 failure: failWithError) { corpus in
                     
                     if corpus.status == .analyzed {
-                        trained = true
+                        processed = true
+                    } else if corpus.status == .undetermined {
+                        let message = "There was an error when processing the corpus, please check " +
+                        "and fix the errors before trying again."
+                        XCTFail(message)
                     }
                     expectation2.fulfill()
             }
             waitForExpectations()
             
             if tries > 10 {
-                XCTFail("Customization is not ready. Please check the customization errors.")
+                XCTFail("The corpus is taking too long to process. Please try again later.")
             }
             
             sleep(3)
-        }
+        } while(!processed)
         
         let description3 = "Delete the new corpus."
         let expectation3 = self.expectation(description: description3)

        }
        waitForExpectations()
        
        trained = false
        tries = 0
        while(!trained) {
            tries += 1
            let description3 = "Wait until the customization is trained."
            let expectation3 = self.expectation(description: description3)

        }
        waitForExpectations()
        
        var processed = false
        var tries = 0
        repeat {
            tries += 1
            let description2 = "Wait until the corpus is processed before deleting it."
            let expectation2 = self.expectation(description: description2)
