search & index: change 'before' logic, and tests.

Change-Id: I62f43f26b295c46b9da63efe018d324f9105606b
Merge "search & index: change 'before' logic, and tests."
corpus: keep permanode claims sorted in memory

Change-Id: Ic0387a3789c10036e21f5e2eb10101a0ae23b0b7