Add tests for stale lock handling

Enough tests to make sure that all LUA scripts work.
merge fix-parallel-deletion-of-stale-locks