Implements and add tests for tlv decoding