Refactoring Locking interface and add two simple locking tests

1. Fix Defect dead lock