De-duplicated a bunch of test code.

Dear god people, come on. Are we programmers or what.