Refactored json2csv.js into object to facilitate testing