more locking tests and bug fixes