Content Uploads: Adding indexing and error checking

Once these are checked, the code ought to be ready for review.

- [x]  Clean up code
- [x] Add tests