Ensure that updates to the index are only performed serially, to avoid race condition
Refactor to ease testing