add -O and -G to test command

they are available on Linux and OS X, and now ported to fish
use wstat in test command to follow symbolic link