diff --git a/Makefile_tests.am b/Makefile_tests.am
index aef4123..b999c5c 100644
--- a/Makefile_tests.am
+++ b/Makefile_tests.am
@@ -121,10 +121,9 @@ tests_test_selfhosting_new_empty_SOURCES = tests/test_selfhosting_new_empty.cc
 tests_test_selfhosting_new_empty_LDADD = $(tests_ldadd)
 tests_test_selfhosting_new_empty_CPPFLAGS = $(tests_cppflags)
 
-tests_test_selfhosting_new_from_example_SOURCES = tests/test_selfhosting_new_from_example.cc
-tests_test_selfhosting_new_from_example_LDADD = $(tests_ldadd)
-tests_test_selfhosting_new_from_example_CPPFLAGS = $(tests_cppflags)
-
+tests_test_selfhosting_new_from_example_SOURCES = tests/test_selfhosting_new_from_example.cc  $(glom_source_files)
+tests_test_selfhosting_new_from_example_LDADD = $(glom_all_libs)
+tests_test_selfhosting_new_from_example_CPPFLAGS = $(tests_cppflags_ui)
 
 # UI Tests:
 
diff --git a/glom/mode_data/datawidget/dialog_choose_id.cc b/glom/mode_data/datawidget/dialog_choose_id.cc
index 3f251f1..b234529 100644
--- a/glom/mode_data/datawidget/dialog_choose_id.cc
+++ b/glom/mode_data/datawidget/dialog_choose_id.cc
@@ -20,7 +20,7 @@
 
 #include "dialog_choose_id.h"
 #include <glom/utils_ui.h> //For bold_message()).
-//#include <libgnome/gnome-i18n.h>
+#include <iostream>
 #include <glibmm/i18n.h>
 
 namespace Glom
@@ -110,8 +110,15 @@ void Dialog_ChooseID::on_button_quickfind()
   }
   else
   {
+    Document* document = get_document();
+    if(!document)
+    {
+      std::cerr << G_STRFUNC << ": document is null." << std::endl;
+      return;
+    }
+  
     const Gnome::Gda::SqlExpr where_clause =
-      Utils::get_find_where_clause_quick(get_document(), m_table_name,
+      Utils::get_find_where_clause_quick(document, m_table_name,
         Gnome::Gda::Value(criteria));
     on_box_find_criteria(where_clause);
   }
@@ -172,7 +179,9 @@ bool Dialog_ChooseID::init_db_details(const Glib::ustring& table_name, const Gli
   m_table_name = table_name;
   m_layout_platform = layout_platform;
 
-  m_label_table_name->set_text( get_document()->get_table_title(m_table_name) );
+  Document* document = get_document();
+  if(document)
+    m_label_table_name->set_text( document->get_table_title(m_table_name) );
 
   //Start by asking for find criteria:
   m_stage = STAGE_FIND;
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index 292af5b..c0fc549 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -114,6 +114,9 @@ DbAddDel::DbAddDel()
 
 DbAddDel::~DbAddDel()
 {
+  //Work around this (apparently GTK+) bug: https://bugzilla.gnome.org/show_bug.cgi?id=660347
+  remove_all_columns();
+  
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   Application* pApp = get_application();
   if(pApp)
diff --git a/tests/test_selfhosting_new_from_example.cc b/tests/test_selfhosting_new_from_example.cc
index a36bac6..ecd79ce 100644
--- a/tests/test_selfhosting_new_from_example.cc
+++ b/tests/test_selfhosting_new_from_example.cc
@@ -24,6 +24,8 @@
 #include <libglom/init.h>
 #include <libglom/privs.h>
 #include <libglom/db_utils.h>
+#include <glom/mode_data/datawidget/dialog_choose_id.h>
+#include <glom/glade_utils.h>
 #include <giomm/file.h>
 #include <iostream>
 
@@ -107,8 +109,11 @@ void cleanup()
   }
 }
 
-int main()
+int main(int argc, char *argv[])
 {
+  Gtk::Main kit(argc, argv);
+  //Gsv::init(); //Our .glade files contain gtksourceview widgets too.
+
   Glom::libglom_init();
 
   // Get a URI for a test file:
@@ -199,9 +204,38 @@ int main()
     cleanup();
   g_assert(recreated);
 
-  cleanup();
+  
+  Glom::DataWidgetChildren::Dialog_ChooseID* dialog = 0;
+  Glom::Utils::get_glade_widget_derived_with_warning(dialog);
 
+  if(dialog)
+  {
+    //Discover the related table, in the relationship that uses this ID field:
+    Glib::ustring related_table_name = "publishers";
+    dialog->set_document(&document);
+    const bool inited = dialog->init_db_details(related_table_name, Glom::Base_DB::get_active_layout_platform(&document));
+    if(!inited)
+    {
+      cleanup();
+      return EXIT_FAILURE;
+    }
+
+    const int response = dialog->run();
+    dialog->hide();
+    if(response == Gtk::RESPONSE_OK)
+    {
+      //Get the chosen field:
+      Gnome::Gda::Value chosen_id;
+      dialog->get_id_chosen(chosen_id);
+      std::cout << "chosen_id=" << chosen_id.to_string() << std::endl;
+    }
+
+    delete dialog;
+  }
+  
   Glom::libglom_deinit();
 
+  cleanup();
+
   return EXIT_SUCCESS;
 }
