Removing used code
Removed unnecessary nested code
Using adapter to call function_exists
Unit tests for the lock method / issue #98 fix