Fixes a bug in hasNext() iterator

Sometimes, iterating on a RqlCursor throws an exeception because hasNext() incorrectly returns true in some cases.