Fix failing test and clean up the if conditions