Fix check on unicode strings, should support both Python 2/3