refactor: improve CSV exporter + add tests for it