karma refactoring