Fix refactoring bug in wait_until_all_members function