Added some error checking to data source and added test cases to test aggregation