Refactor test utilities for injecting HTTP requests.