fixed some tests
refactored some stuff
refactored code in different packages