These functions repeat a lot of the same code. It probably makes sense to generalize them, but for the time being this should get a lot of the system tests back to passing.