Various bugfixes to make tests pass (#33)
Bugfixes related to unit tests (#33)