Add test and fix for multibyte encoding issues