Improve test helpers with factories and enclosed visibility.