[Slowhack] add primary.xml generation
 + gz file name
 + fixed unit tests
 + minor fixes