Fix failing tests

Also fixes #170