             for (keyword, keywordResults) in result.keywordResults! {
                 validateSTTKeywordResults(keyword, keywordResults: keywordResults)
             }
-        } else if settings.keywords?.count > 0 && !final {
-            XCTAssertEqual(result.keywordResults!.count, 0)
         } else {
-            XCTAssertNil(result.keywordResults)
+            let isEmpty = (result.keywordResults?.count == 0)
+            let isNil = (result.keywordResults == nil)
+            XCTAssert(isEmpty || isNil)
         }
 
         if settings.wordAlternativesThreshold != nil && final {

            for wordAlternatives in result.wordAlternatives! {
                validateSTTWordAlternativeResults(wordAlternatives)
            }
        } else if settings.wordAlternativesThreshold != nil && !final {
            XCTAssertEqual(result.wordAlternatives!.count, 0)
        } else {
            XCTAssertNil(result.wordAlternatives)
        }
    }


                validateSTTWordTimestamp(timestamp)
            }
        } else {
            let isEmpty = (transcription.timestamps?.count == 0)
            let isNil = (transcription.timestamps == nil)
            XCTAssert(isEmpty || isNil)
        }

        if settings.wordConfidence == true && final {
