Fix string encoding test on Python 3