refactored dynamic csv template and added test