A test framework for verifying concurrency anomalies

The rest of this file is just code moved from kv/db.go