Bugfixes found when attempting to run unit tests (#33)