refactor the ApiGatewayFactory and associated test suite