Improves error message on bad config; refactors common code

Minor typo here