token: add token bucket accounting helper plus test