Some StatsAggregator refactoring

Moved StatsAggregator to its own file, made it more pep8 compliant. Also, added some basic test coverage for this class.