fix to indexes

fixed range calculation and added more tests; will add more tests over
the next few days to make sure all edge cases are accounted for