Refactor common logic to a test base class