Improve tests. Refactor out xml transform function

Improved xml transform tests. Moved xml transform to it's own
module/file.
Also created a generic createCollection function under
transformToCollection. Accepts json, creates a collection, returns
next()