diff --git a/gajim/history_manager.py b/gajim/history_manager.py
index 1598ea46b385951710a9298093f491dd29e5e6f8..3e767840295f5404687ec6bb298fbdc4e369b4ca 100644
--- a/gajim/history_manager.py
+++ b/gajim/history_manager.py
@@ -55,7 +55,6 @@
 from gajim.common.const import JIDConstant
 from gajim.common.const import KindConstant
 from gajim.common.const import ShowConstant
-from gajim.common.settings import Settings
 
 
 def is_standalone():
@@ -76,6 +75,8 @@ def init_gtk():
 if is_standalone():
     init_gtk()
 
+    from gajim.common.settings import Settings
+
     try:
         shortargs = 'hvsc:l:p:'
         longargs = 'help verbose separate config-path= loglevel= profile='
@@ -100,6 +101,8 @@ def init_gtk():
     app.settings = Settings()
     app.settings.init()
     app.load_css_config()
+else:
+    from gajim.common.settings import Settings
 
 from gajim.common import helpers
 from gajim.gui.dialogs import ErrorDialog
diff --git a/test/unit/test_gui_interface.py b/test/unit/test_gui_interface.py
index 41274dfd4447a89b6ea33bdd36538212e4d28d8c..6ad2d734b5bcc093e1d2e8e627cfbd3a0653b53e 100644
--- a/test/unit/test_gui_interface.py
+++ b/test/unit/test_gui_interface.py
@@ -3,6 +3,9 @@
 '''
 import unittest
 
+import gajim.gui
+gajim.gui.init('gtk')
+
 from test import lib
 lib.setup_env()
 
