KV data parsing. Also tests.