[Refactoring] delete nested if statement
fixed tests