generate distinct groups and make sure to extend and not append lists; add tests