Extract and test Histogram logic