refactor index resetting
add test [ci skip]