Fixes and tests for tx-encode and tx-decode.