BUG 12800 fixed inconsistent behavior of last_valid_index and first_valid_index
- [x] closes #12800
- [x] tests added / passed
- [ ] passes `git diff upstream/master | flake8 --diff`
- [ ] whatsnew entry
