key-value-test: make mutex and condition variable local. Better program exit condition.