test/p21: rewrite tests to reduce duplication