In other words binsize for the refence is adapted such that the number of points per bin is equal.
Updated the test script