Implement, test and fix varint decoding/encoding