Make testable the encapsulated code of a library

Duplicate of Make some library's code private some consumers, but public for tests

Locking.