Make source_encoding stricter about its arguments, and test it everywhere