factor out get_context_generator

Adds another test seam.