         let string = sampleListString
         let expected = sampleListRange
 
-        let minimumIndex = expected.location
-        let maximumIndex = expected.location + expected.length
-
         for index in (0 ..< string.length) {
             let retrieved = string.rangeOfTextList(atIndex: index)
 
-            if index >= minimumIndex && index < maximumIndex {
+            if isIndexWithinListRange(index) {
                 XCTAssert(retrieved != nil)
                 XCTAssert(expected.location == retrieved!.location)
                 XCTAssert(expected.length == retrieved!.length)

        let expectedContents = sampleListContents
        let expectedRange = sampleListRange

        // Verify!
        let minimumIndex = expectedRange.location
        let maximumIndex = expectedRange.location + expectedRange.length

        for index in (0 ..< string.length) {
            let retrievedContents = string.textListContents(followingIndex: index)

            if index >= minimumIndex && index < maximumIndex {
                XCTAssertNotNil(retrievedContents)
                let delta = index - minimumIndex
                let expectedSubstring = expectedContents.substringFromIndex(expectedContents.startIndex.advancedBy(delta))
                XCTAssertEqual(retrievedContents!.string, expectedSubstring)
            } else {
                XCTAssertNil(retrievedContents)
            }
        }
    }

    var sampleListRange: NSRange {
        return (sampleListString.string as NSString).rangeOfString(sampleListContents)
    }

    func isIndexWithinListRange(index: Int) -> Bool {
        let expectedRange = sampleListRange
        let minimumIndex = expectedRange.location
        let maximumIndex = expectedRange.location + expectedRange.length

        return index >= minimumIndex && index < maximumIndex
    }
}
