This is the 3rd time I've seen this snippet; seems worthy of abstracting into testutils?