more refinements to iterate
factor test logic into own function