util: fix bug in to_uid function

It must check for string_types, not str only.
tests: import unicode_literals from future