Optimize test structure

Extracted from #414
Please add documentation for the new options.