optimize groupWhen
groupWhen test