Fix an off by one error that caused a unit test to occasionally crash.