 func containsAttribute(key: String, value: String) -> MatcherFunc<NSAttributedStringAttribute> {
     return MatcherFunc { actualExpression, failureMessage in
         failureMessage.postfixMessage = "contain attribute <[\(key) : \(value)]>"
-        // expect(attrs["NSColor"]!.description) == "UIDeviceRGBColorSpace 1 0 0 1"
-        let attributeDescription = actualExpression.evaluate()![key]!.description
-        return attributeDescription.rangeOfString(value) != nil
+        if let attributeStringAttribute = actualExpression.evaluate(),
+           let attr = attributeStringAttribute[key] {
+                let attributeDescription = attr.description
+                return attributeDescription.rangeOfString(value) != nil
+        }
+        return false
     }
 }
 

                
                expect(result.length) == count(example)
                expect(result.string) == example
            }
            
            it("string concatenation with function composition") {

                expect(attributesOfSecondWord).to(containsAttribute("NSFont", "font-style: normal; font-size: 11.00pt"))
            }

            it("combine multiple string to text") {
                let formatter = thongs_color(UIColor.redColor()) <*> thongs_font(largeFont)
                let formatter2 = thongs_color(UIColor.blueColor()) <*> thongs_font(smallFont)
                let result = formatter ~~> "two" <+> thongs_string(" ") <+> formatter2 ~~> "three"
                
                expect(result.length) == count("two three")
                expect(result.string) == "two three"

                let attributesOfFirstWord = result.attributesAt(0, 3)
                expect(attributesOfFirstWord.count) == 2
                expect(attributesOfFirstWord).to(containsAttribute("NSColor", "UIDeviceRGBColorSpace 1 0 0 1"))
                expect(attributesOfFirstWord).to(containsAttribute("NSFont", "font-family: \".HelveticaNeueInterface-MediumP4\"; font-weight: bold"))
                expect(attributesOfFirstWord).to(containsAttribute("NSFont", "font-style: normal; font-size: 23.00pt"))

                let attributesOfSpace = result.attributesAt(3, 1)
                expect(attributesOfSpace.count) == 0

                let attributesOfSecondWord = result.attributesAt(4, 5)
                expect(attributesOfFirstWord.count) == 2
                expect(attributesOfSecondWord).to(containsAttribute("NSColor", "UIDeviceRGBColorSpace 0 0 1 1"))
                expect(attributesOfSecondWord).to(containsAttribute("NSFont", "font-family: \".HelveticaNeueInterface-MediumP4\"; font-weight: bold"))
                expect(attributesOfSecondWord).to(containsAttribute("NSFont", "font-style: normal; font-size: 11.00pt"))
            }
        }
    }
}
