fix and test index division by zero
Related: #19336, this implements the most important parts of the parametrization requested there.

- [ ] closes #xxxx
- [x] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry
