Simplifying acquisition of lock handler
Readability improvements
Adding the missing tests
Making sure the test sets the state back to the way it was before it begun
Removing unnecessary test