Refactor: Moved redundant code in dedicated function

Please double check gocourse static - in the old version were less checks. It _should_ work, but a test might be a good idea.