Optimize isFunction only when appropriate.

Closes #1929.

@jdalton: How did you test this? Seems PhantomJS doesn't play nicely with `typeof` or `toString.call` (returning `object` and `[object Int8ArrayConstructor]`).
I'd probably use a chain for all this