Fix Formula#installed_prefix logic

Due to the precedence of "and" relative to "||", this was not working as
intended; but because #version influences #prefix, the outcome was still
correct. So we can simplify this method quite a bit, and take the
opportunity to share code with #prefix.