Bugs/2674/utf8

It's fixing #2674. It also significantly increases performance of UTF encoding.
Can you add some small explanation of test besides issue number?