Factor out some more common code in smoke.py