Add some tests for generating UTF8 encodings from \uabcd strings. Fix encode bug.

The encode bug was for 2 byte UTF-8, but probably was a bug in 3 byte.