Refactored PollingCommand and added unit tests. This commit does not
change existing uses of PollingCommand, so they are broken until my next
commit.