[refactor] clean up logic in testmempoolaccept
Summary:
Cleans up reundant code and reduces the diff of the next commit.
This is a backport of core#21062 [1/4]
https://github.com/bitcoin/bitcoin/pull/21062/commits/9db10a55061e09021ff8ea1d6637d99f7959035f
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, sdulfari
Reviewed By: #bitcoin_abc, sdulfari
Differential Revision: https://reviews.bitcoinabc.org/D11778