added check to verify that mutex is locked during call to wait