Refactor histogram code to HistogramHelper for better testing/encapsulation