Refactor gulp file into helper methods, and also attempt to fix infinite loop in watch-test task