Fixes simplification of more than two summations

Fixes #8596