refactored code and added karma testing framework