Update kv functions.
Flat lets and version increment.
Added unit tests.