New unit test, and hacky fix for, encoding issues (#338)

The fix is hacky, but it's better than the current situation I hope.  Could always merge this, and then look for a less hacky fix...