Move redundant boilerplate from tests to a common parent class

Some preparatory cleanup so the new tests I'll write won't have to contain the same boilerplate code over and over.