Fix choice encoding

Fixes bug #15 - choice encoding had no tests and was broken
Please move merge this with a line above.