Fix failing tests, refactor