We can simplify code in a bunch of places using a useful factory. Part of https://github.com/ooni/probe/issues/2121.