Refactor code to separate config gathering from spec file generation
This is a prerequisite for testing the rendering logic without invoking
the whole program. But I think it also makes it much easier to see what
is going on.
I used slightly non-standard formatting with extra whitespace because
the invocation was hard to rid otherwise.