Simplify tests for comparing branches/tags
Created by: varungandhi-src
I stumbled across some of this code, and it seemed overly generalized for adding more test cases in the future. So I've removed a bunch of single-iteration loops and factored out the common logic for some tests.
Test plan
N/A.