Add teardown and fix tests