Extract test generation helpers.

So that a similar mechanism can be used for the unit testing.
Move cli test data to a subfolder.