Add regression test for encoding behavior.

Broken in fc97ecd.