Adds comprehensive unit tests

I started working on this ahead of intending to implement a fix for issue 67, however I am going with sompylasar's recommended solution there so I won't be making any changes.  Still I thought it beneficial to finish out the unit tests.  The structure of the tests is a bit odd because I am trying to keep them DRY; in particular, I am unsatisfied with need for the if statement around the background update tests at the end.  However, I decided to stick with this it has the advantage of simplicity.