Sanitize identifiers in tests to make sure all are triggered

Python 3 would not recognize "test_*" function names with non-identifier
characters in them. This adds a sanitize_ident() function that takes care
of making sure that all characters in an identifier are valid. Also, some
constants missing the u"" prefix do have it now, for Python 2.