Added html_safe to csv output rows.
Modified scope as previous method won't work in testing.