Use "brew list <name>" instead of grepping the output of "brew list". Fix for #5488

```brew list <name>``` fails with an error message and returns false when the package is not installed. Seems like a more robust way of querying for installed packages.