Upload null pointer exception

Fixed some null pointer issues and added more test coverage. Uncovered and fixed an upload JSON serialization error on empty lists