Fix some encoding problems, more tests