I've tested it and I can't see anything wrong with it either.

I suspect the bug is in your test code. It's very easy to mix up high, the maximum index, with N, the count, or high + 1.