fixing tests, minor refactors and more tests