Adding CSV output.

Also added unit tests for json data & CSV output.