Better tests of metrics collector bucketing functions. Fix bug in metrics_func_loop that was revealed by better tests.