Trivial semantic improvement.
Add unit tests for the state module.

python-coverage(1) says that the code achieves 98% coverage:

> Name    Stmts   Miss Branch BrPart  Cover   Missing
> ---------------------------------------------------
> state      71      0     10      2    98%