Refactored shard lock and added stress test