Moved stuff around and added karma tests
Refactored