Refactor/karma tests