added tests
refactored stuff