modified decoder and add tests for it