This commit takes the querying logic from each function and moves it into a single function (called, aptly, query).

In addition, the logic is modified so that 403s are handled as a special case of stop_for_status: the source of those errors is fairly consist and we can provide more useful advice to the user than "ARGH! NOT AUTHORISED!"