Add a test for Unicode attribute values
Fix UnicodeEncodeError with attribute values