Added test_protocol.c and fixed a small bug when encoding a varint of 0