Create unittests for circuit timeout tracking

We don't have any unittests for tracking circuit timeouts, and hence it's hard to catch bugs like legacy/trac#26121 (moved).