Unbreak scripts using proper test(1) syntax for integer comparison, also add a missing 'fi'