Trying to solve problem in if condition before executing karma tests