Better encoding checks in the protocol specs

And the tests now fail where they should
Fixed encoding of multibyte characters

This closes #4