An old PR (#7623) was merged after #9585. The old code was incompatible with the new
changes, but none of the lines caused a git conflict so the merge was allowed.
The incompatible changes caused the tests to fail. This fixes the old code to
work with the new changes.
* Switch to WithinDuration to improve test
This test was flaky before because of the time logic. Now it uses
WithinDuration and should be correct.
Fixes https://github.com/hashicorp/consul/issues/6857.