Fix #2711

Changes:

- Fix issue #2711 by making sure the expression to be matched is an `Expr` if the pattern is an `Expr`
- Fix bug in `manualintegrate` by ensuring that in u-substitution, the constant does not contain the original symbol (i.e. the constant is actually constant).