Made my own "which" equivalent

For some strange reason using which in a command substition to feed the
test command will always return true. This changeset replaces "test -x
(which foo)" everywhere with my own, hacky function, command_exists.