Fix ahead-behind results

The logic is currently reversed. Fix that.

I went and checked manually with git each pair in the tests that I changed.

This is one for backporting too @vmg.