Massive refactoring for fun
fix test