Fix most of the tests beforeEach and afterEach