Finish decoder; add unit tests