Overhaul lock_test.R