Factor out request-fn-making thing

Thanks @radix for the suggestion. Hopefully this will make it possible
to test :)