Fix if test

Issue found by David Binderman with cppcheck.