fixes negative index issue in testthat