Refactor response conversion for testing