Various improvements re character encoding and testing

These are mostly improvements I needed myself, but they're relevant for #7, #9 and #10.