Fix unit test by looping to end+1