refactored karma testing