Added encoding tests from Dave's commit on master.