Cherry-picking from 07dbdf3e1
Writing Jasmine tests for metadata in download cart

Also moved a couple of supporting functions lower in file
Whitespace