added tests, refactored shit, fixed bugs
added tests, refactored code