Finish tests, fix serious decoding bugs