Changed order of if-clause + added test