mattdrayer/rebase-20140926: Repaired faulty keygen logic

@antoviaque @e-kolpakov -- found some faults with the existing change we made to util/request.py in the solutions fork -- take a look at this update -- tests pass on my end but would appreciate confirmation