move calculations to flush(); make Gauge report bucket boundary as timestamp; add tests