Fix up tests

Fixes the tests as well as a bit of cleaning here and there