Add auto refresh feature and some tests.

Also fixes an unsatisfied variable name error in one of the tests.