code refactoring and karma config