Extract common gateway function to a separate test class