Better testing of single_instance().

Thoroughly testing the decorator, unlike before. Made _LockManager and
its derivatives more testable.

Fixed some testing bugs too.