Factor out rate computation into the RateSpan class.
- Factored out the piece of code that computes the rate of changes to make
  it easier to understand and test.