Adding check for SystemSetting in runAsSystem before usage. This fixes some unit tests and potential issues.