Adding locking to avoid https://github.com/nose-devs/nose/issues/753