Fix travis PR branch builds
Conditional env vars not allowed on travis
Repair builds of PRs
Solve issue #138. Add tests.