fixes to key order
add some preliminar tests