fix synthax errors and and encoder unit tests
fix remaining bugs and improve testing coverage