[PATCH v3 1/8] mf/tests: Move and split some helper code around.