Minor refactor to extract reusable test code