Factor out common code (without Travis CI)