Instead of unlocking after the file operation, change exclusive locks back to shared locks during post hooks, and unlock after that. Also added unit tests to test locking in pre-hooks, during operation and post-hooks.