unit test + fix to how invalid index is determined (IsInvalidIndex in IndexStats)