Huge refactoring made for tests