Add tests cases and fix UTF-8 support