Fix the herp

Fixed bugs in format_packet() and decode_packet()
Added reentrancy
Added comprehensive test (test_runner.c and packet_test.c)
I notice there are a lot of comments... can we remove them?