Refactor some of the locking module
Introduce Mocha tests, starting with the locking module