Adds tests for locking and relocking with a gap in between.
Cleans up tests a bit.