Add protection against permanent sync locking
Update unit tests for sync locking.
asdf
Review fixes