Combine two test functions used to fetch tx lists.

The two functions are nearly identical, so rather than repeating the
test code, refactor it into a separate function that takes a flag.