Fix "keys" message parsing

Add encoding and decoding tests