Wildcards cannot express condition, you cannot tell it that the first word should be !test and that the second word is optional without accepting a match such as "!test ", with only a space after it

* meaning anything, !test* does match !testhello, you want at least !test * but as said, it matches on "!test " which can be problematic.
You can use a general * for the matchtext and then check that $1 == !test, but that means the on text event triggers for any text spoken before deciding to do nothing on irrelevant text, meaning more processing, so using !test * is still the best idea, to avoid matching on any messages, and then you check for $2 and $3

Code:
on *:text:!test *:#:{
  if ($2 == $null) {
    echo use !test [word] [number]
    ;return is not really required in this simple example.
    ;return
  }
  elseif ($3 != $null) && ($3 !isnum) {
    echo $!3 is not num
  }
  else { 
    echo good
  }
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel