Fixed bug and added a couple tests. Incremented patch version to 0.2.2.