Reduce test code duplication