Fail fast: install stuff on Travis only when needed

Move installation stuff that's not needed in the `script:` section closer to where it's needed, in the `after_success:` section. 

This saves time by avoiding unnecessary installation when a test fails, gives feedback sooner, and frees up Travis build runners.