Add tests for TopHitsAggregation and fix errors found by tests