Added even more tests and refactors