util: fix bug in to_uid function

It must check for string_types, not str only.