Fix bug in encoder.  Now all the encoder assertions pass the test set