fix decode_packet
make encode accept decode'ed term
some tests
decode: use bin instead of unknown for consistency
encode: always accept Rest
some more tests
some more tests