encoder: misc fixes for encoder and test cases