Clean refactoring of lock with a mixin class

Resources that need a locking mechanism must inherit from WithLockMixin.
This will provide a `self.lock` method to lock the resource.

It is currently used by classes `engine.base.Base`, `engine.base.inBase`
and `engine.ktbs_root.KtbsRoot`.
Add a unit test suite for KtbsRoot locking