diff --git a/res/core/messages.xml b/res/core/messages.xml
index f09530e0f..8c5db1b4d 100644
--- a/res/core/messages.xml
+++ b/res/core/messages.xml
@@ -468,7 +468,7 @@
     <text locale="de">"Die Ausrüstung von $unit($unit) scheint unsichtbar. ($int36($id))"</text>
     <text locale="en">"$unit($unit)'s equipment is invisible. ($int36($id))"</text>
   </message>
-  <message name="curseinfo::magicresistance_unit" section="events">
+  <message name="magicresistance_unit" section="events">
     <type>
       <arg name="unit" type="unit"/>
       <arg name="id" type="int"/>
@@ -476,7 +476,7 @@
     <text locale="de">"Die natürliche Widerstandskraft gegen Verzauberung ist gestärkt. ($int36($id))"</text>
     <text locale="en">"The magical resistance has been strengthened. ($int36($id))"</text>
   </message>
-  <message name="curseinfo::magicresistance_building" section="events">
+  <message name="magicresistance_building" section="events">
     <type>
       <arg name="building" type="building"/>
       <arg name="id" type="int"/>
diff --git a/src/alchemy.test.c b/src/alchemy.test.c
index b25498d82..7510933fe 100644
--- a/src/alchemy.test.c
+++ b/src/alchemy.test.c
@@ -26,13 +26,14 @@ static void test_herbsearch(CuTest * tc)
     const item_type *itype;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    test_inject_messagetypes();
+    r = test_create_region(0, 0, NULL);
     rc = rc_get_or_create("dragon");
     rc->flags |= RCF_UNARMEDGUARD;
     u2 = test_create_unit(test_create_faction(rc), r);
     setguard(u2, true);
 
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     u = test_create_unit(f, r);
     itype = test_create_itemtype("rosemary");
 
diff --git a/src/attributes/otherfaction.test.c b/src/attributes/otherfaction.test.c
index 614163830..8417ed3e3 100644
--- a/src/attributes/otherfaction.test.c
+++ b/src/attributes/otherfaction.test.c
@@ -38,8 +38,8 @@ static void test_otherfaction(CuTest *tc) {
     faction *f;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    f = test_create_faction(0);
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    f = test_create_faction(NULL);
     config_set("stealth.faction.other", "1");
     CuAssertIntEquals(tc, true, rule_stealth_other());
     CuAssertPtrEquals(tc, u->faction, visible_faction(f, u));
diff --git a/src/attributes/stealth.test.c b/src/attributes/stealth.test.c
index 52e1c9a59..36c020e7d 100644
--- a/src/attributes/stealth.test.c
+++ b/src/attributes/stealth.test.c
@@ -15,7 +15,7 @@ static void test_stealth(CuTest *tc) {
     unit *u;
 
     test_setup();
-    u = test_create_unit(test_create_faction(test_create_race("human")), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(test_create_race("human")), test_create_region(0, 0, NULL));
     set_level(u, SK_STEALTH, 2);
     CuAssertIntEquals(tc, -1, u_geteffstealth(u));
     CuAssertIntEquals(tc, 2, eff_stealth(u, u->region));
diff --git a/src/battle.test.c b/src/battle.test.c
index e25999018..07107383e 100644
--- a/src/battle.test.c
+++ b/src/battle.test.c
@@ -36,7 +36,7 @@ static void test_make_fighter(CuTest * tc)
 
     test_setup();
     test_create_horse();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     f = test_create_faction(NULL);
     au = test_create_unit(f, r);
     enable_skill(SK_MAGIC, true);
@@ -94,7 +94,7 @@ static void test_defenders_get_building_bonus(CuTest * tc)
 
     test_setup();
     btype = setup_castle();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     bld = test_create_building(r, btype);
 
     du = test_create_unit(test_create_faction(NULL), r);
@@ -138,7 +138,7 @@ static void test_attackers_get_no_building_bonus(CuTest * tc)
     building_type * btype;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     btype = setup_castle();
     btype->flags |= BTF_FORTIFICATION;
     bld = test_create_building(r, btype);
@@ -169,7 +169,7 @@ static void test_building_bonus_respects_size(CuTest * tc)
 
     test_setup();
     btype = setup_castle();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     btype->flags |= BTF_FORTIFICATION;
     bld = test_create_building(r, btype);
     bld->size = 10;
@@ -235,7 +235,7 @@ static void test_natural_armor(CuTest * tc)
 
     test_setup();
     rc = test_create_race("human");
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     set_level(u, SK_STAMINA, 2);
     CuAssertIntEquals(tc, 0, rc_armor_bonus(rc));
     CuAssertIntEquals(tc, 0, natural_armor(u));
@@ -262,7 +262,7 @@ static void test_calculate_armor(CuTest * tc)
     variant v50p = frac_make(1, 2);
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     ibelt = it_get_or_create(rt_get_or_create("trollbelt"));
     ishield = it_get_or_create(rt_get_or_create("shield"));
     ashield = new_armortype(ishield, 0.0, v50p, 1, ATF_SHIELD);
@@ -333,7 +333,7 @@ static void test_magic_resistance(CuTest *tc)
     variant v10p = frac_make(1, 10);
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     ishield = it_get_or_create(rt_get_or_create("shield"));
     ashield = new_armortype(ishield, 0.0, v50p, 1, ATF_SHIELD);
     ichain = it_get_or_create(rt_get_or_create("chainmail"));
@@ -404,7 +404,7 @@ static void test_projectile_armor(CuTest * tc)
     variant v50p = frac_make(1, 2);
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     ishield = it_get_or_create(rt_get_or_create("shield"));
     ashield = new_armortype(ishield, 0.0, v50p, 1, ATF_SHIELD);
     ichain = it_get_or_create(rt_get_or_create("chainmail"));
@@ -439,14 +439,14 @@ static void test_battle_skilldiff(CuTest *tc)
 
     test_setup();
 
-    r = test_create_region(0, 0, 0);
-    ud = test_create_unit(test_create_faction(0), r);
-    ua = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    ud = test_create_unit(test_create_faction(NULL), r);
+    ua = test_create_unit(test_create_faction(NULL), r);
     td.fighter = setup_fighter(&b, ud);
     td.index = 0;
     ta.fighter = setup_fighter(&b, ua);
     ta.index = 0;
-    ua = test_create_unit(test_create_faction(0), r);
+    ua = test_create_unit(test_create_faction(NULL), r);
     CuAssertIntEquals(tc, 0, skilldiff(ta, td, 0));
 
     ta.fighter->person[0].attack = 2;
@@ -475,15 +475,15 @@ static void test_battle_skilldiff_building(CuTest *tc)
     test_setup();
     btype = setup_castle();
 
-    r = test_create_region(0, 0, 0);
-    ud = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    ud = test_create_unit(test_create_faction(NULL), r);
     ud->building = test_create_building(ud->region, btype);
-    ua = test_create_unit(test_create_faction(0), r);
+    ua = test_create_unit(test_create_faction(NULL), r);
     td.fighter = setup_fighter(&b, ud);
     td.index = 0;
     ta.fighter = setup_fighter(&b, ua);
     ta.index = 0;
-    ua = test_create_unit(test_create_faction(0), r);
+    ua = test_create_unit(test_create_faction(NULL), r);
     CuAssertIntEquals(tc, 0, skilldiff(ta, td, 0));
 
     ud->building->size = 10;
@@ -524,7 +524,7 @@ static void test_drain_exp(CuTest *tc)
 
     test_setup();
     config_set("study.random_progress", "0");
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     set_level(u, SK_STAMINA, 3);
 
     CuAssertIntEquals(tc, 3, unit_skill(u, SK_STAMINA)->level);
diff --git a/src/creport.test.c b/src/creport.test.c
index 04a307506..bacf8def0 100644
--- a/src/creport.test.c
+++ b/src/creport.test.c
@@ -37,8 +37,8 @@ static void test_cr_unit(CuTest *tc) {
     unit *u;
 
     test_setup();
-    f = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
     u = test_create_unit(f, r);
     renumber_unit(u, 1234);
 
@@ -91,8 +91,8 @@ static void test_cr_resources(CuTest *tc) {
 
     setup_resources();
 
-    f = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
     u = test_create_unit(f, r);
     set_level(u, SK_QUARRYING, 1);
     r->land->horses = 1;
@@ -169,8 +169,8 @@ static void test_cr_mallorn(CuTest *tc) {
     
     setup_resources();
 
-    f = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
     r->land->horses = 1;
     r->land->peasants = 200;
     r->land->money = 300;
@@ -230,9 +230,9 @@ static void test_cr_factionstealth(CuTest *tc) {
     ally *al;
 
     test_setup();
-    f1 = test_create_faction(0);
-    f2 = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
+    f1 = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
     u = test_create_unit(f1, r);
 
     /* report to ourselves */
diff --git a/src/donations.test.c b/src/donations.test.c
index 13e435a6b..e61ca2536 100644
--- a/src/donations.test.c
+++ b/src/donations.test.c
@@ -3,6 +3,7 @@
 
 #include <kernel/faction.h>
 #include <kernel/region.h>
+#include <util/message.h>
 #include <tests.h>
 
 #include <CuTest.h>
@@ -12,9 +13,10 @@ static void test_add_donation(CuTest *tc) {
     region *r;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    f1 = test_create_faction(0);
-    f2 = test_create_faction(0);
+    mt_register(mt_new_va("donation", "from:faction", "to:faction", "amount:int", NULL));
+    r = test_create_region(0, 0, NULL);
+    f1 = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
     add_donation(f1, f2, 100, r);
     report_donations();
     CuAssertPtrNotNull(tc, test_find_messagetype(r->individual_messages->msgs, "donation"));
diff --git a/src/economy.test.c b/src/economy.test.c
index bd5858c7f..ff21f4622 100644
--- a/src/economy.test.c
+++ b/src/economy.test.c
@@ -35,9 +35,9 @@ static void test_give_control_building(CuTest * tc)
     region *r;
 
     test_setup();
-    f = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
-    b = test_create_building(r, 0);
+    f = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
+    b = test_create_building(r, NULL);
     u1 = test_create_unit(f, r);
     u_set_building(u1, b);
     u2 = test_create_unit(f, r);
@@ -56,9 +56,9 @@ static void test_give_control_ship(CuTest * tc)
     region *r;
 
     test_setup();
-    f = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
-    sh = test_create_ship(r, 0);
+    f = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
+    sh = test_create_ship(r, NULL);
     u1 = test_create_unit(f, r);
     u_set_ship(u1, sh);
     u2 = test_create_unit(f, r);
@@ -141,11 +141,19 @@ static struct unit *create_recruiter(void) {
     return u;
 }
 
+static void setup_production(void) {
+    init_resources();
+    mt_register(mt_new_va("produce", "unit:unit", "region:region", "amount:int", "wanted:int", "resource:resource", NULL));
+    mt_register(mt_new_va("income", "unit:unit", "region:region", "amount:int", "wanted:int", "mode:int", NULL));
+    mt_register(mt_new_va("buy", "unit:unit", "money:int", NULL));
+    mt_register(mt_new_va("buyamount", "unit:unit", "amount:int", "resource:resource", NULL));
+}
+
 static void test_heroes_dont_recruit(CuTest * tc) {
     unit *u;
 
     test_setup();
-    init_resources();
+    setup_production();
     u = create_recruiter();
 
     fset(u, UFL_HERO);
@@ -163,7 +171,7 @@ static void test_normals_recruit(CuTest * tc) {
     unit *u;
 
     test_setup();
-    init_resources();
+    setup_production();
     u = create_recruiter();
     unit_addorder(u, create_order(K_RECRUIT, default_locale, "1"));
 
@@ -227,7 +235,7 @@ static void test_trade_insect(CuTest *tc) {
     const item_type *it_silver;
 
     test_setup();
-    init_resources();
+    setup_production();
     test_create_locale();
     setup_terrains(tc);
     r = setup_trade_region(tc, get_terrain("swamp"));
@@ -259,7 +267,7 @@ static void test_buy_cmd(CuTest *tc) {
     const resource_type *rt_silver;
     const item_type *it_luxury;
     test_setup();
-    init_resources();
+    setup_production();
     test_create_locale();
     setup_terrains(tc);
     r = setup_trade_region(tc, test_create_terrain("swamp", LAND_REGION));
@@ -312,7 +320,7 @@ static void test_tax_cmd(CuTest *tc) {
     econ_request *taxorders = 0;
 
     test_setup();
-    init_resources();
+    setup_production();
     config_set("taxing.perlevel", "20");
     f = test_create_faction(NULL);
     r = test_create_region(0, 0, NULL);
@@ -361,6 +369,14 @@ static void test_tax_cmd(CuTest *tc) {
     test_teardown();
 }
 
+static void setup_economy(void) {
+    mt_register(mt_new_va("recruit", "unit:unit", "region:region", "amount:int", "want:int", NULL));
+    mt_register(mt_new_va("maintenance", "unit:unit", "building:building", NULL));
+    mt_register(mt_new_va("maintenancefail", "unit:unit", "building:building", NULL));
+    mt_register(mt_new_va("maintenance_nowork", "building:building", NULL));
+    mt_register(mt_new_va("maintenance_noowner", "building:building", NULL));
+}
+
 /** 
  * see https://bugs.eressea.de/view.php?id=2234
  */
@@ -374,10 +390,11 @@ static void test_maintain_buildings(CuTest *tc) {
     item_type *itype;
 
     test_setup();
+    setup_economy();
     btype = test_create_buildingtype("Hort");
     btype->maxsize = 10;
-    r = test_create_region(0, 0, 0);
-    f = test_create_faction(0);
+    r = test_create_region(0, 0, NULL);
+    f = test_create_faction(NULL);
     u = test_create_unit(f, r);
     b = test_create_building(r, btype);
     itype = test_create_itemtype("money");
@@ -433,8 +450,9 @@ static void test_recruit(CuTest *tc) {
     faction *f;
 
     test_setup();
-    f = test_create_faction(0);
-    u = test_create_unit(f, test_create_region(0, 0, 0));
+    setup_economy();
+    f = test_create_faction(NULL);
+    u = test_create_unit(f, test_create_region(0, 0, NULL));
     CuAssertIntEquals(tc, 1, u->number);
     CuAssertIntEquals(tc, 1, f->num_people);
     CuAssertIntEquals(tc, 1, f->num_units);
@@ -458,7 +476,7 @@ static void test_income(CuTest *tc)
     unit *u;
     test_setup();
     rc = test_create_race("nerd");
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     CuAssertIntEquals(tc, 20, income(u));
     u->number = 5;
     CuAssertIntEquals(tc, 100, income(u));
@@ -472,9 +490,9 @@ static void test_modify_material(CuTest *tc) {
     resource_mod *mod;
 
     test_setup();
-    init_resources();
+    setup_production();
 
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     set_level(u, SK_WEAPONSMITH, 1);
 
     /* the unit's race gets 2x savings on iron used to produce goods */
@@ -521,9 +539,9 @@ static void test_modify_skill(CuTest *tc) {
     resource_mod *mod;
 
     test_setup();
-    init_resources();
+    setup_production();
 
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     set_level(u, SK_WEAPONSMITH, 1);
 
     itype = test_create_itemtype("iron");
@@ -580,13 +598,13 @@ static void test_modify_production(CuTest *tc) {
     double d = 0.6;
 
     test_setup();
-    init_resources();
+    setup_production();
 
     /* make items from other items (turn silver to stone) */
     rt_silver = get_resourcetype(R_SILVER);
     itype = test_create_itemtype("stone");
     rtype = itype->rtype;
-    u = test_create_unit(test_create_faction(0), test_create_region(0,0,0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     make_item(u, itype, 1);
     CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error_cannotmake"));
     CuAssertIntEquals(tc, 0, get_item(u, itype));
diff --git a/src/give.test.c b/src/give.test.c
index 5afdc3842..1f1985b6a 100644
--- a/src/give.test.c
+++ b/src/give.test.c
@@ -52,13 +52,33 @@ static void setup_give(struct give *env) {
         init_locale(env->lang);
         env->f1->locale = env->lang;
     }
+
+    /* success messages: */
+    mt_register(mt_new_va("receive_person", "unit:unit", "target:unit", "amount:int", NULL));
+    mt_register(mt_new_va("give_person", "unit:unit", "target:unit", "amount:int", NULL));
+    mt_register(mt_new_va("give_person_peasants", "unit:unit", "amount:int", NULL));
+    mt_register(mt_new_va("give_person_ocean", "unit:unit", "amount:int", NULL));
+    mt_register(mt_new_va("receive", "unit:unit", "target:unit", "resource:resource", "amount:int", NULL));
+    mt_register(mt_new_va("give", "unit:unit", "target:unit", "resource:resource", "amount:int", NULL));
+    mt_register(mt_new_va("give_peasants", "unit:unit", "resource:resource", "amount:int", NULL));
+    /* error messages: */
+    mt_register(mt_new_va("too_many_units_in_faction", "unit:unit", "region:region", "command:order", "allowed:int", NULL));
+    mt_register(mt_new_va("too_many_units_in_alliance", "unit:unit", "region:region", "command:order", "allowed:int", NULL));
+    mt_register(mt_new_va("feedback_no_contact", "unit:unit", "region:region", "command:order", "target:unit", NULL));
+    mt_register(mt_new_va("feedback_give_forbidden", "unit:unit", "region:region", "command:order", NULL));
+    mt_register(mt_new_va("peasants_give_invalid", "unit:unit", "region:region", "command:order", NULL));
+    mt_register(mt_new_va("giverestriction", "unit:unit", "region:region", "command:order", "turns:int", NULL));
+    mt_register(mt_new_va("error_unit_size", "unit:unit", "region:region", "command:order", "maxsize:int", NULL));
+    mt_register(mt_new_va("nogive_reserved", "unit:unit", "region:region", "command:order", "resource:resource", "reservation:int", NULL));
+    mt_register(mt_new_va("race_notake", "unit:unit", "region:region", "command:order", "race:race", NULL));
+    mt_register(mt_new_va("race_noregroup", "unit:unit", "region:region", "command:order", "race:race", NULL));
 }
 
 static void test_give_unit(CuTest * tc) {
     struct give env = { 0 };
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
-    env.f2 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
+    env.f2 = test_create_faction(NULL);
     setup_give(&env);
     config_set("rules.give.max_men", "0");
     give_unit(env.src, env.dst, NULL);
@@ -77,8 +97,8 @@ static void test_give_unit(CuTest * tc) {
 static void test_give_unit_limits(CuTest * tc) {
     struct give env = { 0 };
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
-    env.f2 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
+    env.f2 = test_create_faction(NULL);
     setup_give(&env);
     CuAssertIntEquals(tc, 1, env.f1->num_units);
     CuAssertIntEquals(tc, 1, env.f2->num_units);
@@ -95,7 +115,7 @@ static void test_give_unit_limits(CuTest * tc) {
 static void test_give_unit_to_peasants(CuTest * tc) {
     struct give env = { 0 };
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
     env.f2 = 0;
     setup_give(&env);
     rsetpeasants(env.r, 0);
@@ -108,7 +128,7 @@ static void test_give_unit_to_peasants(CuTest * tc) {
 static void test_give_unit_to_ocean(CuTest * tc) {
     struct give env = { 0 };
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
     env.f2 = 0;
     setup_give(&env);
     env.r->terrain = test_create_terrain("ocean", SEA_REGION);
@@ -120,7 +140,7 @@ static void test_give_unit_to_ocean(CuTest * tc) {
 static void test_give_men(CuTest * tc) {
     struct give env = { 0 };
     test_setup_ex(tc);
-    env.f2 = env.f1 = test_create_faction(0);
+    env.f2 = env.f1 = test_create_faction(NULL);
     setup_give(&env);
     CuAssertPtrEquals(tc, 0, give_men(1, env.src, env.dst, NULL));
     CuAssertIntEquals(tc, 2, env.dst->number);
@@ -134,7 +154,7 @@ static void test_give_men_magicians(CuTest * tc) {
     message * msg;
 
     test_setup_ex(tc);
-    env.f2 = env.f1 = test_create_faction(0);
+    env.f2 = env.f1 = test_create_faction(NULL);
     setup_give(&env);
     set_level(env.src, SK_MAGIC, 1);
     CuAssertPtrNotNull(tc, msg = give_men(1, env.src, env.dst, NULL));
@@ -145,7 +165,7 @@ static void test_give_men_magicians(CuTest * tc) {
 
     p = rpeasants(env.r);
     CuAssertPtrNotNull(tc, msg = disband_men(1, env.dst, NULL));
-    CuAssertStrEquals(tc, "give_person_peasants", (const char *)msg->parameters[0].v);
+    CuAssertStrEquals(tc, "give_person_peasants", test_get_messagetype(msg));
     CuAssertIntEquals(tc, 0, env.dst->number);
     CuAssertIntEquals(tc, p+1, rpeasants(env.r));
     msg_release(msg);
@@ -156,16 +176,17 @@ static void test_give_men_magicians(CuTest * tc) {
 static void test_give_men_limit(CuTest * tc) {
     struct give env = { 0 };
     message *msg;
+
     test_setup_ex(tc);
-    env.f2 = test_create_faction(0);
-    env.f1 = test_create_faction(0);
+    env.f2 = test_create_faction(NULL);
+    env.f1 = test_create_faction(NULL);
     setup_give(&env);
     config_set("rules.give.max_men", "1");
 
     /* below the limit, give men, increase newbies counter */
     usetcontact(env.dst, env.src);
     msg = give_men(1, env.src, env.dst, NULL);
-    CuAssertStrEquals(tc, "give_person", (const char *)msg->parameters[0].v);
+    CuAssertStrEquals(tc, "give_person", test_get_messagetype(msg));
     CuAssertIntEquals(tc, 2, env.dst->number);
     CuAssertIntEquals(tc, 0, env.src->number);
     CuAssertIntEquals(tc, 1, env.f2->newbies);
@@ -174,7 +195,7 @@ static void test_give_men_limit(CuTest * tc) {
     /* beyond the limit, do nothing */
     usetcontact(env.src, env.dst);
     msg = give_men(2, env.dst, env.src, NULL);
-    CuAssertStrEquals(tc, "error129", (const char *)msg->parameters[3].v);
+    CuAssertStrEquals(tc, "error129", test_get_messagetype(msg));
     CuAssertIntEquals(tc, 2, env.dst->number);
     CuAssertIntEquals(tc, 0, env.src->number);
     CuAssertIntEquals(tc, 0, env.f1->newbies);
@@ -188,12 +209,12 @@ static void test_give_men_in_ocean(CuTest * tc) {
     message * msg;
 
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
     env.f2 = 0;
     setup_give(&env);
     env.r->terrain = test_create_terrain("ocean", SEA_REGION);
     msg = disband_men(1, env.src, NULL);
-    CuAssertStrEquals(tc, "give_person_ocean", (const char *)msg->parameters[0].v);
+    CuAssertStrEquals(tc, "give_person_ocean", test_get_messagetype(msg));
     CuAssertIntEquals(tc, 0, env.src->number);
     msg_release(msg);
     test_teardown();
@@ -202,7 +223,7 @@ static void test_give_men_in_ocean(CuTest * tc) {
 static void test_give_men_too_many(CuTest * tc) {
     struct give env = { 0 };
     test_setup_ex(tc);
-    env.f2 = env.f1 = test_create_faction(0);
+    env.f2 = env.f1 = test_create_faction(NULL);
     setup_give(&env);
     CuAssertPtrEquals(tc, 0, give_men(2, env.src, env.dst, NULL));
     CuAssertIntEquals(tc, 2, env.dst->number);
@@ -214,7 +235,7 @@ static void test_give_cmd_limit(CuTest * tc) {
     struct give env = { 0 };
     unit *u;
     test_setup_ex(tc);
-    env.f2 = env.f1 = test_create_faction(0);
+    env.f2 = env.f1 = test_create_faction(NULL);
     setup_give(&env);
     u = env.src;
     scale_number(u, 2);
@@ -230,7 +251,7 @@ static void test_give_men_none(CuTest * tc) {
     message * msg;
 
     test_setup_ex(tc);
-    env.f2 = env.f1 = test_create_faction(0);
+    env.f2 = env.f1 = test_create_faction(NULL);
     setup_give(&env);
     msg = give_men(0, env.src, env.dst, NULL);
     CuAssertStrEquals(tc, "error96", test_get_messagetype(msg));
@@ -245,12 +266,12 @@ static void test_give_men_other_faction(CuTest * tc) {
     message * msg;
 
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
-    env.f2 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
+    env.f2 = test_create_faction(NULL);
     setup_give(&env);
     usetcontact(env.dst, env.src);
     msg = give_men(1, env.src, env.dst, NULL);
-    CuAssertStrEquals(tc, "give_person", (const char *)msg->parameters[0].v);
+    CuAssertStrEquals(tc, "give_person", test_get_messagetype(msg));
     CuAssertIntEquals(tc, 2, env.dst->number);
     CuAssertIntEquals(tc, 0, env.src->number);
     msg_release(msg);
@@ -263,8 +284,8 @@ static void test_give_men_requires_contact(CuTest * tc) {
     order *ord;
 
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
-    env.f2 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
+    env.f2 = test_create_faction(NULL);
     setup_give(&env);
     msg = give_men(1, env.src, env.dst, NULL);
     CuAssertStrEquals(tc, "feedback_no_contact", test_get_messagetype(msg));
@@ -286,7 +307,7 @@ static void test_give_men_not_to_self(CuTest * tc) {
     struct give env = { 0 };
     message * msg;
     test_setup_ex(tc);
-    env.f2 = env.f1 = test_create_faction(0);
+    env.f2 = env.f1 = test_create_faction(NULL);
     setup_give(&env);
     msg = give_men(1, env.src, env.src, NULL);
     CuAssertStrEquals(tc, "error10", test_get_messagetype(msg));
@@ -300,12 +321,12 @@ static void test_give_peasants(CuTest * tc) {
     message * msg;
 
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
     env.f2 = 0;
     setup_give(&env);
     rsetpeasants(env.r, 0);
     msg = disband_men(1, env.src, NULL);
-    CuAssertStrEquals(tc, "give_person_peasants", (const char*)msg->parameters[0].v);
+    CuAssertStrEquals(tc, "give_person_peasants", test_get_messagetype(msg));
     CuAssertIntEquals(tc, 0, env.src->number);
     CuAssertIntEquals(tc, 1, rpeasants(env.r));
     msg_release(msg);
@@ -316,15 +337,15 @@ static void test_give(CuTest * tc) {
     struct give env = { 0 };
 
     test_setup_ex(tc);
-    env.f2 = env.f1 = test_create_faction(0);
+    env.f2 = env.f1 = test_create_faction(NULL);
     setup_give(&env);
 
     i_change(&env.src->items, env.itype, 10);
-    CuAssertIntEquals(tc, 0, give_item(10, env.itype, env.src, env.dst, 0));
+    CuAssertIntEquals(tc, 0, give_item(10, env.itype, env.src, env.dst, NULL));
     CuAssertIntEquals(tc, 0, i_get(env.src->items, env.itype));
     CuAssertIntEquals(tc, 10, i_get(env.dst->items, env.itype));
 
-    CuAssertIntEquals(tc, -1, give_item(10, env.itype, env.src, env.dst, 0));
+    CuAssertIntEquals(tc, -1, give_item(10, env.itype, env.src, env.dst, NULL));
     CuAssertIntEquals(tc, 0, i_get(env.src->items, env.itype));
     CuAssertIntEquals(tc, 10, i_get(env.dst->items, env.itype));
     test_teardown();
@@ -336,7 +357,7 @@ static void test_give_cmd(CuTest * tc) {
 
     test_setup_ex(tc);
     env.lang = test_create_locale();
-    env.f2 = env.f1 = test_create_faction(0);
+    env.f2 = env.f1 = test_create_faction(NULL);
     setup_give(&env);
 
     i_change(&env.src->items, env.itype, 10);
@@ -374,11 +395,11 @@ static void test_give_okay(CuTest * tc) {
     struct give env = { 0 };
 
     test_setup_ex(tc);
-    env.f2 = env.f1 = test_create_faction(0);
+    env.f2 = env.f1 = test_create_faction(NULL);
     setup_give(&env);
 
     config_set("rules.give.flags", "0");
-    CuAssertPtrEquals(tc, 0, check_give(env.src, env.dst, 0));
+    CuAssertPtrEquals(tc, 0, check_give(env.src, env.dst, NULL));
     test_teardown();
 }
 
@@ -387,12 +408,12 @@ static void test_give_denied_by_rules(CuTest * tc) {
     struct message *msg;
 
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
-    env.f2 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
+    env.f2 = test_create_faction(NULL);
     setup_give(&env);
 
     config_set("rules.give.flags", "0");
-    CuAssertPtrNotNull(tc, msg = check_give(env.src, env.dst, 0));
+    CuAssertPtrNotNull(tc, msg = check_give(env.src, env.dst, NULL));
     msg_release(msg);
     test_teardown();
 }
@@ -402,12 +423,12 @@ static void test_give_dead_unit(CuTest * tc) {
     struct message *msg;
 
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
-    env.f2 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
+    env.f2 = test_create_faction(NULL);
     setup_give(&env);
     env.dst->number = 0;
     freset(env.dst, UFL_ISNEW);
-    CuAssertPtrNotNull(tc, msg = check_give(env.src, env.dst, 0));
+    CuAssertPtrNotNull(tc, msg = check_give(env.src, env.dst, NULL));
     msg_release(msg);
     test_teardown();
 }
@@ -416,12 +437,12 @@ static void test_give_new_unit(CuTest * tc) {
     struct give env = { 0 };
 
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
-    env.f2 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
+    env.f2 = test_create_faction(NULL);
     setup_give(&env);
     env.dst->number = 0;
     fset(env.dst, UFL_ISNEW);
-    CuAssertPtrEquals(tc, 0, check_give(env.src, env.dst, 0));
+    CuAssertPtrEquals(tc, 0, check_give(env.src, env.dst, NULL));
     test_teardown();
 }
 
@@ -431,7 +452,7 @@ static void test_give_invalid_target(CuTest *tc) {
     order *ord;
 
     test_setup_ex(tc);
-    env.f1 = test_create_faction(0);
+    env.f1 = test_create_faction(NULL);
     env.f2 = 0;
     setup_give(&env);
 
diff --git a/src/guard.test.c b/src/guard.test.c
index e105ddcb1..6264aad21 100644
--- a/src/guard.test.c
+++ b/src/guard.test.c
@@ -26,8 +26,8 @@ static void test_is_guarded(CuTest *tc) {
     test_setup();
     rc = rc_get_or_create("dragon");
     rc->flags |= RCF_UNARMEDGUARD;
-    r = test_create_region(0, 0, 0);
-    u1 = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u1 = test_create_unit(test_create_faction(NULL), r);
     u2 = test_create_unit(test_create_faction(rc), r);
     CuAssertPtrEquals(tc, 0, is_guarded(r, u1));
     setguard(u2, true);
@@ -45,9 +45,9 @@ static void test_guard_unskilled(CuTest * tc)
     test_setup();
     itype = it_get_or_create(rt_get_or_create("sword"));
     new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
-    r = test_create_region(0, 0, 0);
-    u = test_create_unit(test_create_faction(0), r);
-    ug = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u = test_create_unit(test_create_faction(NULL), r);
+    ug = test_create_unit(test_create_faction(NULL), r);
     i_change(&ug->items, itype, 1);
 
     setguard(ug, true);
@@ -69,9 +69,9 @@ static void test_guard_armed(CuTest * tc)
     test_setup();
     itype = it_get_or_create(rt_get_or_create("sword"));
     new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
-    r = test_create_region(0, 0, 0);
-    u = test_create_unit(test_create_faction(0), r);
-    ug = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u = test_create_unit(test_create_faction(NULL), r);
+    ug = test_create_unit(test_create_faction(NULL), r);
     i_change(&ug->items, itype, 1);
     set_level(ug, SK_MELEE, 2);
     setguard(ug, true);
@@ -88,8 +88,8 @@ static void test_is_guard(CuTest * tc)
     test_setup();
     itype = it_get_or_create(rt_get_or_create("sword"));
     new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
-    r = test_create_region(0, 0, 0);
-    ug = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    ug = test_create_unit(test_create_faction(NULL), r);
     i_change(&ug->items, itype, 1);
     setguard(ug, true);
     CuAssertIntEquals(tc, 0, armedmen(ug, false));
@@ -109,8 +109,8 @@ static void test_guard_unarmed(CuTest * tc)
     test_setup();
     rc = test_create_race("mountainguard");
     rc->flags |= RCF_UNARMEDGUARD;
-    r = test_create_region(0, 0, 0);
-    u = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u = test_create_unit(test_create_faction(NULL), r);
     ug = test_create_unit(test_create_faction(rc), r);
     setguard(ug, true);
     CuAssertPtrEquals(tc, ug, is_guarded(r, u));
@@ -123,8 +123,8 @@ static void test_guard_monsters(CuTest * tc)
     region *r;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    u = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u = test_create_unit(test_create_faction(NULL), r);
     ug = test_create_unit(get_monsters(), r);
     setguard(ug, true);
     CuAssertPtrEquals(tc, ug, is_guarded(r, u));
@@ -145,7 +145,7 @@ static void test_update_guard(CuTest * tc)
     itype = it_get_or_create(rt_get_or_create("sword"));
     new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
     r = test_create_region(0, 0, t_plain);
-    ug = test_create_unit(test_create_faction(0), r);
+    ug = test_create_unit(test_create_faction(NULL), r);
     i_change(&ug->items, itype, 1);
     set_level(ug, SK_MELEE, 1);
     setguard(ug, true);
@@ -172,7 +172,7 @@ static void test_guard_on(CuTest * tc)
     itype = it_get_or_create(rt_get_or_create("sword"));
     new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
     r = test_create_region(0, 0, t_plain);
-    ug = test_create_unit(test_create_faction(0), r);
+    ug = test_create_unit(test_create_faction(NULL), r);
     i_change(&ug->items, itype, 1);
     set_level(ug, SK_MELEE, 1);
     ug->thisorder = create_order(K_GUARD, ug->faction->locale, NULL);
diff --git a/src/items/xerewards.test.c b/src/items/xerewards.test.c
index a027a8838..27c34b812 100644
--- a/src/items/xerewards.test.c
+++ b/src/items/xerewards.test.c
@@ -16,7 +16,9 @@
 static void test_manacrystal(CuTest *tc) {
     struct item_type *itype;
     unit *u;
+
     test_setup();
+    test_inject_messagetypes();
 
     u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     itype = test_create_itemtype("manacrystal");
@@ -47,6 +49,7 @@ static void test_skillpotion(CuTest *tc) {
     int initialWeeks_Magic = 0;
 
     test_setup();
+    test_inject_messagetypes();
     test_create_world();
     u = test_create_unit(test_create_faction(NULL), findregion(0, 0));
     itype = test_create_itemtype("skillpotion");
diff --git a/src/kernel/alliance.test.c b/src/kernel/alliance.test.c
index e3790ba13..00fe1f4d9 100644
--- a/src/kernel/alliance.test.c
+++ b/src/kernel/alliance.test.c
@@ -69,8 +69,8 @@ static void test_alliance_dead_faction(CuTest *tc) {
     alliance *al;
 
     test_setup();
-    f = test_create_faction(0);
-    f2 = test_create_faction(0);
+    f = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
     al = makealliance(42, "Hodor");
     setalliance(f, al);
     setalliance(f2, al);
@@ -91,9 +91,9 @@ static void test_alliance_cmd(CuTest *tc) {
     struct alliance *al;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    u1 = test_create_unit(test_create_faction(0), r);
-    u2 = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u1 = test_create_unit(test_create_faction(NULL), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
     unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)));
     unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_INVITE], itoa36(u2->faction->no)));
     unit_addorder(u2, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_JOIN], itoa36(42)));
@@ -117,9 +117,9 @@ static void test_alliance_limits(CuTest *tc) {
     struct region *r;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    u1 = test_create_unit(test_create_faction(0), r);
-    u2 = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u1 = test_create_unit(test_create_faction(NULL), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
 
     config_set("rules.limit.alliance", "1");
     unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)));
@@ -142,9 +142,9 @@ static void test_alliance_cmd_kick(CuTest *tc) {
 
     test_setup();
     al = makealliance(42, "Hodor");
-    r = test_create_region(0, 0, 0);
-    u1 = test_create_unit(test_create_faction(0), r);
-    u2 = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u1 = test_create_unit(test_create_faction(NULL), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
     setalliance(u1->faction, al);
     setalliance(u2->faction, al);
 
@@ -161,9 +161,9 @@ static void test_alliance_cmd_no_invite(CuTest *tc) {
     struct region *r;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    u1 = test_create_unit(test_create_faction(0), r);
-    u2 = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u1 = test_create_unit(test_create_faction(NULL), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
     unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)));
     unit_addorder(u2, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_JOIN], itoa36(42)));
     CuAssertTrue(tc, is_allied(u1->faction, u1->faction));
@@ -183,9 +183,9 @@ static void test_alliance_cmd_leave(CuTest *tc) {
 
     test_setup();
     al = makealliance(42, "Hodor");
-    r = test_create_region(0, 0, 0);
-    u1 = test_create_unit(test_create_faction(0), r);
-    u2 = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u1 = test_create_unit(test_create_faction(NULL), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
     setalliance(u1->faction, al);
     setalliance(u2->faction, al);
 
@@ -204,9 +204,9 @@ static void test_alliance_cmd_transfer(CuTest *tc) {
 
     test_setup();
     al = makealliance(42, "Hodor");
-    r = test_create_region(0, 0, 0);
-    u1 = test_create_unit(test_create_faction(0), r);
-    u2 = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u1 = test_create_unit(test_create_faction(NULL), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
     setalliance(u1->faction, al);
     setalliance(u2->faction, al);
     CuAssertPtrEquals(tc, u1->faction, alliance_get_leader(al));
diff --git a/src/kernel/ally.test.c b/src/kernel/ally.test.c
index c5c47298f..66542a298 100644
--- a/src/kernel/ally.test.c
+++ b/src/kernel/ally.test.c
@@ -8,7 +8,7 @@
 static void test_ally(CuTest * tc)
 {
     ally * al = 0;
-    struct faction * f1 = test_create_faction(0);
+    struct faction * f1 = test_create_faction(NULL);
 
     ally_add(&al, f1);
     CuAssertPtrNotNull(tc, al);
diff --git a/src/kernel/build.test.c b/src/kernel/build.test.c
index 88b1bab8c..eab2a6f00 100644
--- a/src/kernel/build.test.c
+++ b/src/kernel/build.test.c
@@ -30,12 +30,13 @@ typedef struct build_fixture {
 
 static unit * setup_build(build_fixture *bf) {
     test_setup();
+    test_inject_messagetypes();
     init_resources();
 
     test_create_itemtype("stone");
     test_create_buildingtype("castle");
     bf->rc = test_create_race("human");
-    bf->r = test_create_region(0, 0, 0);
+    bf->r = test_create_region(0, 0, NULL);
     bf->f = test_create_faction(bf->rc);
     assert(bf->rc && bf->f && bf->r);
     bf->u = test_create_unit(bf->f, bf->r);
@@ -255,11 +256,11 @@ static void test_build_destroy_road(CuTest *tc)
     message *m;
 
     test_setup();
-    mt_register(mt_new_va("destroy_road", "unit:unit", "from:region", "to:region", 0));
+    mt_register(mt_new_va("destroy_road", "unit:unit", "from:region", "to:region", NULL));
     r2 = test_create_region(1, 0, 0);
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     rsetroad(r, D_EAST, 100);
-    u = test_create_unit(f = test_create_faction(0), r);
+    u = test_create_unit(f = test_create_faction(NULL), r);
     u->orders = ord = create_order(K_DESTROY, f->locale, "%s %s", LOC(f->locale, parameters[P_ROAD]), LOC(f->locale, directions[D_EAST]));
 
     CuAssertIntEquals(tc, 0, destroy_cmd(u, ord));
@@ -309,11 +310,12 @@ static void test_build_destroy_road_guard(CuTest *tc)
     order *ord;
 
     test_setup();
+    test_inject_messagetypes();
     test_create_region(1, 0, 0);
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     rsetroad(r, D_EAST, 100);
     ug = test_create_guard(r, 0, 0);
-    u = test_create_unit(f = test_create_faction(0), r);
+    u = test_create_unit(f = test_create_faction(NULL), r);
     u->orders = ord = create_order(K_DESTROY, f->locale, "%s %s", LOC(f->locale, parameters[P_ROAD]), LOC(f->locale, directions[D_EAST]));
 
     set_level(u, SK_ROAD_BUILDING, 1);
@@ -341,10 +343,11 @@ static void test_build_destroy_road_limit(CuTest *tc)
     order *ord;
 
     test_setup();
+    test_inject_messagetypes();
     test_create_region(1, 0, 0);
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     rsetroad(r, D_EAST, 100);
-    u = test_create_unit(f = test_create_faction(0), r);
+    u = test_create_unit(f = test_create_faction(NULL), r);
     u->orders = ord = create_order(K_DESTROY, f->locale, "1 %s %s", LOC(f->locale, parameters[P_ROAD]), LOC(f->locale, directions[D_EAST]));
 
     set_level(u, SK_ROAD_BUILDING, 1);
@@ -365,7 +368,7 @@ static void test_build_destroy_cmd(CuTest *tc) {
     faction *f;
 
     test_setup();
-    u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
     u->thisorder = create_order(K_DESTROY, f->locale, NULL);
     CuAssertIntEquals(tc, 138, destroy_cmd(u, u->thisorder));
     CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error138"));
diff --git a/src/kernel/building.test.c b/src/kernel/building.test.c
index 9d49374f2..8d5b86dc9 100644
--- a/src/kernel/building.test.c
+++ b/src/kernel/building.test.c
@@ -356,8 +356,8 @@ static void test_active_building(CuTest *tc) {
 
     btype = test_create_buildingtype("castle");
     assert(btype && btype->maxsize == -1);
-    b = test_create_building(r = test_create_region(0, 0, 0), btype);
-    u = test_create_unit(test_create_faction(0), r);
+    b = test_create_building(r = test_create_region(0, 0, NULL), btype);
+    u = test_create_unit(test_create_faction(NULL), r);
     CuAssertIntEquals(tc, false, building_is_active(b));
     CuAssertPtrEquals(tc, NULL, active_building(u, btype));
 
@@ -387,8 +387,8 @@ static void test_safe_building(CuTest *tc) {
 
     test_setup();
     btype = test_create_buildingtype("castle");
-    u1 = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    u2 = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u1 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    u2 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     CuAssertIntEquals(tc, false, in_safe_building(u1, u2));
     u1->building = test_create_building(u1->region, btype);
     CuAssertIntEquals(tc, false, in_safe_building(u1, u2));
@@ -418,12 +418,12 @@ static void test_cmp_castle_size(CuTest *tc) {
     unit *u1, *u2;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     b1 = test_create_building(r, NULL);
     b2 = test_create_building(r, NULL);
-    u1 = test_create_unit(test_create_faction(0), r);
+    u1 = test_create_unit(test_create_faction(NULL), r);
     u_set_building(u1, b1);
-    u2 = test_create_unit(test_create_faction(0), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
     u_set_building(u2, b2);
     b1->size = 5;
     b2->size = 10;
@@ -441,7 +441,7 @@ static void test_cmp_wage(CuTest *tc) {
     test_setup();
     btype = test_create_buildingtype("castle");
     btype->taxes = 100;
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     b1 = test_create_building(r, btype);
     b2 = test_create_building(r, btype);
     b1->size = 5;
@@ -462,14 +462,14 @@ static void test_cmp_taxes(CuTest *tc) {
     test_setup();
     btype = test_create_buildingtype("castle");
     btype->taxes = 100;
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     b1 = test_create_building(r, btype);
     b2 = test_create_building(r, btype);
     b1->size = 5;
     b2->size = 10;
-    u1 = test_create_unit(test_create_faction(0), r);
+    u1 = test_create_unit(test_create_faction(NULL), r);
     u_set_building(u1, b1);
-    u2 = test_create_unit(test_create_faction(0), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
     u_set_building(u2, b2);
     CuAssertPtrEquals(tc, b2, largestbuilding(r, cmp_taxes, false));
     CuAssertTrue(tc, cmp_taxes(b1, b2) < 0);
@@ -486,7 +486,7 @@ static void test_cmp_current_owner(CuTest *tc) {
 
     test_setup();
     config_set("rules.region_owners", "1");
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     btype = test_create_buildingtype("watch");
     btype->construction->maxsize = 1;
     btype->taxes = 200;
@@ -499,9 +499,9 @@ static void test_cmp_current_owner(CuTest *tc) {
     CuAssertIntEquals(tc, 1, buildingeffsize(b1, false));
     b2->size = 1;
     CuAssertIntEquals(tc, 1, buildingeffsize(b2, false));
-    u1 = test_create_unit(test_create_faction(0), r);
+    u1 = test_create_unit(test_create_faction(NULL), r);
     u_set_building(u1, b1);
-    u2 = test_create_unit(test_create_faction(0), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
     u_set_building(u2, b2);
     region_set_owner(r, u1->faction, turn);
     CuAssertPtrEquals(tc, b1, largestbuilding(r, cmp_current_owner, false));
diff --git a/src/kernel/command.test.c b/src/kernel/command.test.c
index 91c95e800..d173474f2 100644
--- a/src/kernel/command.test.c
+++ b/src/kernel/command.test.c
@@ -43,7 +43,7 @@ static void test_command(CuTest * tc) {
     stree_add(st, "six", parser_six);
     CuAssertPtrNotNull(tc, st->root);
     CuAssertPtrEquals(tc, st->root, stree_find(st, loc));
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     u->thisorder = create_order(K_ALLIANCE, loc, "two");
     do_command(st->root, u, u->thisorder);
     CuAssertIntEquals(tc, u->number, 2);
diff --git a/src/kernel/config.test.c b/src/kernel/config.test.c
index a27bd81e1..7a2097ce4 100644
--- a/src/kernel/config.test.c
+++ b/src/kernel/config.test.c
@@ -27,7 +27,7 @@ static void test_read_unitid(CuTest *tc) {
     lang = test_create_locale();
     /* note that the english order is FIGHT, not COMBAT, so this is a poor example */
     t_plain = test_create_terrain("plain", LAND_REGION);
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, t_plain));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, t_plain));
     a = a_add(&u->attribs, a_new(&at_alias));
     a->data.i = atoi36("42"); /* this unit is also TEMP 42 */
 
@@ -72,7 +72,7 @@ static void test_getunit(CuTest *tc) {
     lang = test_create_locale();
     /* note that the english order is FIGHT, not COMBAT, so this is a poor example */
     t_plain = test_create_terrain("plain", LAND_REGION);
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, t_plain));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, t_plain));
     a = a_add(&u->attribs, a_new(&at_alias));
     a->data.i = atoi36("42"); /* this unit is also TEMP 42 */
     r = test_create_region(1, 0, t_plain);
diff --git a/src/kernel/curse.c b/src/kernel/curse.c
index 93df39f49..0f215dbee 100644
--- a/src/kernel/curse.c
+++ b/src/kernel/curse.c
@@ -726,6 +726,7 @@ message *cinfo_simple(const void *obj, objtype_t typ, const struct curse * c,
     UNUSED_ARG(obj);
 
     msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
+    /* TODO: this is never NULL, because of the missing_message logic (used in many tests) */
     if (msg == NULL) {
         log_error("There is no curseinfo for %s.\n", c->type->cname);
     }
diff --git a/src/kernel/curse.test.c b/src/kernel/curse.test.c
index d8f0f9ffe..9c74544e1 100644
--- a/src/kernel/curse.test.c
+++ b/src/kernel/curse.test.c
@@ -51,6 +51,7 @@ typedef struct {
 
 static void setup_curse(curse_fixture *fix, const char *name) {
     test_setup();
+    test_inject_messagetypes();
     fix->r = test_create_region(0, 0, NULL);
     fix->u = test_create_unit(test_create_faction(NULL), fix->r);
     fix->c = create_curse(fix->u, &fix->r->attribs, ct_find(name), 1.0, 1, 1.0, 0);
@@ -183,7 +184,7 @@ static void test_curse_flags(CuTest *tc) {
     unit *u;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     c1 = create_curse(u, &u->attribs, &ct_dummy, 1, 1, 1, 0);
     CuAssertPtrEquals(tc, u, c1->magician);
     CuAssertIntEquals(tc, 1, (int)c1->effect);
diff --git a/src/kernel/equipment.test.c b/src/kernel/equipment.test.c
index 77da38a2f..5c0757601 100644
--- a/src/kernel/equipment.test.c
+++ b/src/kernel/equipment.test.c
@@ -34,7 +34,7 @@ static void test_equipment(CuTest * tc)
     equipment_setskill(eq, SK_MAGIC, "5");
     equipment_addspell(eq, sp->sname, 1);
 
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     equip_unit_mask(u, eq, EQUIP_ALL);
     CuAssertIntEquals(tc, 1, i_get(u->items, it_horses));
     CuAssertIntEquals(tc, 5, get_level(u, SK_MAGIC));
diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c
index dfd41434d..904609be5 100644
--- a/src/kernel/faction.test.c
+++ b/src/kernel/faction.test.c
@@ -29,10 +29,10 @@ static void test_destroyfaction_allies(CuTest *tc) {
     ally *al;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    f1 = test_create_faction(0);
+    r = test_create_region(0, 0, NULL);
+    f1 = test_create_faction(NULL);
     test_create_unit(f1, r);
-    f2 = test_create_faction(0);
+    f2 = test_create_faction(NULL);
     al = ally_add(&f1->allies, f2);
     al->status = HELP_FIGHT;
     CuAssertIntEquals(tc, HELP_FIGHT, alliedgroup(0, f1, f2, f1->allies, HELP_ALL));
@@ -48,7 +48,7 @@ static void test_remove_empty_factions_alliance(CuTest *tc) {
     struct alliance *al;
 
     test_setup();
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     al = makealliance(0, "Hodor");
     setalliance(f, al);
     CuAssertPtrEquals(tc, f, alliance_get_leader(al));
@@ -66,7 +66,7 @@ static void test_remove_empty_factions(CuTest *tc) {
     test_setup();
     fm = get_or_create_monsters();
     assert(fm);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     fno = f->no;
     remove_empty_factions();
     CuAssertIntEquals(tc, false, f->_alive);
@@ -83,9 +83,9 @@ static void test_remove_dead_factions(CuTest *tc) {
     int fno;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     fm = get_or_create_monsters();
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     assert(fm && r && f);
     test_create_unit(f, r);
     test_create_unit(fm, r);
@@ -134,7 +134,7 @@ static void test_addfaction(CuTest *tc) {
 static void test_check_passwd(CuTest *tc) {
     faction *f;
     
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     faction_setpassword(f, password_encode("password", PASSWORD_DEFAULT));
     CuAssertTrue(tc, checkpasswd(f, "password"));
     CuAssertTrue(tc, !checkpasswd(f, "assword"));
@@ -159,7 +159,7 @@ static void test_set_origin(CuTest *tc) {
 
     test_setup();
     pl = create_new_plane(0, "", 0, 19, 0, 19, 0);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     CuAssertPtrEquals(tc, 0, f->ursprung);
     faction_setorigin(f, 0, 1, 1);
     CuAssertIntEquals(tc, 0, f->ursprung->id);
@@ -184,7 +184,7 @@ static void test_set_origin_bug(CuTest *tc) {
 
     test_setup();
     pl = create_new_plane(0, "", 0, 19, 0, 19, 0);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     faction_setorigin(f, 0, -10, 3);
     faction_setorigin(f, 0, -13, -4);
     adjust_coordinates(f, &x, &y, pl);
@@ -202,7 +202,7 @@ static void test_max_migrants(CuTest *tc) {
     test_setup();
     rc = test_create_race("human");
     f = test_create_faction(rc);
-    u = test_create_unit(f, test_create_region(0, 0, 0));
+    u = test_create_unit(f, test_create_region(0, 0, NULL));
     CuAssertIntEquals(tc, 0, count_maxmigrants(f));
     rc->flags |= RCF_MIGRANTS;
     CuAssertIntEquals(tc, 0, count_maxmigrants(f));
@@ -238,7 +238,7 @@ static void test_set_email(CuTest *tc) {
     CuAssertIntEquals(tc, -1, check_email("eressea@"));
     CuAssertIntEquals(tc, -1, check_email(""));
     CuAssertIntEquals(tc, -1, check_email(NULL));
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
 
     sprintf(email, "enno");
     faction_setemail(f, email);
diff --git a/src/kernel/group.test.c b/src/kernel/group.test.c
index 4119ced22..d3bf4e2d9 100644
--- a/src/kernel/group.test.c
+++ b/src/kernel/group.test.c
@@ -32,13 +32,13 @@ static void test_group_readwrite_dead_faction(CuTest *tc) {
     int fno;
 
     test_setup();
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     fno = f->no;
     CuAssertPtrEquals(tc, f, factions);
     CuAssertPtrEquals(tc, 0, f->next);
-    f2 = test_create_faction(0);
+    f2 = test_create_faction(NULL);
     CuAssertPtrEquals(tc, f2, factions->next);
-    u = test_create_unit(f2, test_create_region(0, 0, 0));
+    u = test_create_unit(f2, test_create_region(0, 0, NULL));
     CuAssertPtrNotNull(tc, u);
     g = join_group(u, "group");
     CuAssertPtrNotNull(tc, g);
@@ -81,7 +81,7 @@ static void test_group_readwrite(CuTest * tc)
     test_setup();
     mstream_init(&data.strm);
     gamedata_init(&data, &store, RELEASE_VERSION);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     new_group(f, "NW", 42);
     g = new_group(f, "Egoisten", 43);
     key_set(&g->attribs, 44, 44);
@@ -124,8 +124,8 @@ static void test_group(CuTest * tc)
     group *g;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    f = test_create_faction(0);
+    r = test_create_region(0, 0, NULL);
+    f = test_create_faction(NULL);
     assert(r && f);
     u = test_create_unit(f, r);
     assert(u);
diff --git a/src/kernel/item.test.c b/src/kernel/item.test.c
index f27ca1844..f04a22572 100644
--- a/src/kernel/item.test.c
+++ b/src/kernel/item.test.c
@@ -74,7 +74,7 @@ void test_change_item(CuTest * tc)
     test_create_itemtype("iron");
     init_resources();
 
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     test_uchange(tc, u, get_resourcetype(R_IRON));
     test_log_stderr(1);
     test_teardown();
diff --git a/src/kernel/messages.c b/src/kernel/messages.c
index 0aa19a79c..03883f127 100644
--- a/src/kernel/messages.c
+++ b/src/kernel/messages.c
@@ -92,7 +92,7 @@ struct message *msg_feedback(const struct unit *u, struct order *ord,
         log_warning("trying to create message of unknown type \"%s\"\n", name);
         if (!mt_find("missing_feedback")) {
             mt_register(mt_new_va("missing_feedback", "unit:unit", 
-                "region:region", "command:order", "name:string", 0));
+                "region:region", "command:order", "name:string", NULL));
         }
         return msg_message("missing_feedback", "name unit region command",
             name, u, u->region, ord);
@@ -148,6 +148,28 @@ struct message *msg_feedback(const struct unit *u, struct order *ord,
     return msg_create(mtype, args);
 }
 
+static int missing_message_mode;
+
+void message_handle_missing(int mode) {
+    missing_message_mode = mode;
+}
+
+static message *missing_message(const char *name) {
+    if (missing_message_mode == MESSAGE_MISSING_ERROR) {
+        log_error("trying to create undefined message of type \"%s\"\n", name);
+    }
+    else if (missing_message_mode == MESSAGE_MISSING_REPLACE) {
+        log_warning("trying to create undefined message of type \"%s\"\n", name);
+        if (strcmp(name, "missing_message") != 0) {
+            if (!mt_find("missing_message")) {
+                mt_register(mt_new_va("missing_message", "name:string", NULL));
+            }
+            return msg_message("missing_message", "name", name);
+        }
+    }
+    return NULL;
+}
+
 message *msg_message(const char *name, const char *sig, ...)
 /* msg_message("oops_error", "unit region command", u, r, cmd) */
 {
@@ -160,14 +182,7 @@ message *msg_message(const char *name, const char *sig, ...)
     memset(args, 0, sizeof(args));
 
     if (!mtype) {
-        log_warning("trying to create message of unknown type \"%s\"\n", name);
-        if (strcmp(name, "missing_message") != 0) {
-            if (!mt_find("missing_message")) {
-                mt_register(mt_new_va("missing_message", "name:string", 0));
-            }
-            return msg_message("missing_message", "name", name);
-        }
-        return NULL;
+        return missing_message(name);
     }
 
     va_start(vargs, sig);
diff --git a/src/kernel/messages.h b/src/kernel/messages.h
index 59bac9af2..723ed2d01 100644
--- a/src/kernel/messages.h
+++ b/src/kernel/messages.h
@@ -46,6 +46,12 @@ extern "C" {
         int level;
     } msglevel;
 
+#define MESSAGE_MISSING_IGNORE  0
+#define MESSAGE_MISSING_ERROR   1
+#define MESSAGE_MISSING_REPLACE 2
+
+    void message_handle_missing(int mode);
+
     struct message *msg_message(const char *name, const char *sig, ...);
     struct message *msg_feedback(const struct unit *, struct order *cmd,
         const char *name, const char *sig, ...);
diff --git a/src/kernel/messages.test.c b/src/kernel/messages.test.c
index d60f45649..4afe25518 100644
--- a/src/kernel/messages.test.c
+++ b/src/kernel/messages.test.c
@@ -11,6 +11,7 @@ void test_missing_message(CuTest *tc) {
     message *msg;
 
     test_setup();
+    message_handle_missing(MESSAGE_MISSING_REPLACE);
     msg = msg_message("unknown", "unit", NULL);
     CuAssertPtrNotNull(tc, msg);
     CuAssertPtrNotNull(tc, msg->type);
diff --git a/src/kernel/plane.test.c b/src/kernel/plane.test.c
index a5599b1d8..8338cc31f 100644
--- a/src/kernel/plane.test.c
+++ b/src/kernel/plane.test.c
@@ -10,7 +10,7 @@ static void test_plane(CuTest *tc) {
     plane *pl;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     CuAssertPtrEquals(tc, 0, findplane(0, 0));
     CuAssertPtrEquals(tc, 0, getplane(r));
     CuAssertIntEquals(tc, 0, getplaneid(r));
@@ -46,7 +46,7 @@ static void test_origin(CuTest *tc) {
     int x, y;
 
     test_setup();
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     x = 0;
     y = 0;
     adjust_coordinates(f, &x, &y, 0);
diff --git a/src/kernel/pool.test.c b/src/kernel/pool.test.c
index 2bd96bfcf..a3de6c021 100644
--- a/src/kernel/pool.test.c
+++ b/src/kernel/pool.test.c
@@ -23,7 +23,7 @@ void test_reservation(CuTest *tc) {
     test_create_world();
     rtype = rt_get_or_create("money");
     it_get_or_create(rtype);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     r = findregion(0, 0);
     assert(r && f && rtype && rtype->itype);
     u = test_create_unit(f, r);
@@ -53,12 +53,12 @@ void test_pool(CuTest *tc) {
     test_create_world();
     rtype = rt_get_or_create("money");
     it_get_or_create(rtype);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     r = findregion(0, 0);
     assert(r && f && rtype && rtype->itype);
     u1 = test_create_unit(f, r);
     u2 = test_create_unit(f, r);
-    u3 = test_create_unit(test_create_faction(0), r);
+    u3 = test_create_unit(test_create_faction(NULL), r);
     assert(u1 && u2);
     i_change(&u1->items, rtype->itype, 100);
     set_resvalue(u1, rtype->itype, 50);
@@ -99,7 +99,7 @@ void test_pool_bug_2042(CuTest *tc) {
     test_create_world();
     rtype = rt_get_or_create("money");
     it_get_or_create(rtype);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     r = findregion(0, 0);
     assert(r && f && rtype && rtype->itype);
     u1 = test_create_unit(f, r);
@@ -122,12 +122,12 @@ void test_pool_use(CuTest *tc) {
     test_setup();
     test_create_world();
     itype = it_get_or_create(rt_get_or_create("money"));
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     r = findregion(0, 0);
     assert(r && f && itype);
     u1 = test_create_unit(f, r);
     u2 = test_create_unit(f, r);
-    u3 = test_create_unit(test_create_faction(0), r);
+    u3 = test_create_unit(test_create_faction(NULL), r);
     assert(u1 && u2);
     i_change(&u1->items, itype, 100);
     set_resvalue(u1, itype, 50);
@@ -172,7 +172,7 @@ void test_change_resource(CuTest * tc)
     enable_skill(SK_MAGIC, true);
 
     r = findregion(0, 0);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     u = test_create_unit(f, r);
     CuAssertPtrNotNull(tc, u);
     set_level(u, SK_MAGIC, 5);
diff --git a/src/kernel/region.test.c b/src/kernel/region.test.c
index 2daf1a957..4baa807c8 100644
--- a/src/kernel/region.test.c
+++ b/src/kernel/region.test.c
@@ -40,14 +40,14 @@ static void test_region_get_owner(CuTest *tc) {
     unit *u1, *u2;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     b1 = test_create_building(r, NULL);
     b2 = test_create_building(r, NULL);
     b1->size = 5;
     b2->size = 10;
-    u1 = test_create_unit(test_create_faction(0), r);
+    u1 = test_create_unit(test_create_faction(NULL), r);
     u_set_building(u1, b1);
-    u2 = test_create_unit(test_create_faction(0), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
     u_set_building(u2, b2);
     CuAssertPtrEquals(tc, u2->faction, region_get_owner(r));
     test_teardown();
diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c
index 5da8e9cce..4e6e0e2d4 100644
--- a/src/kernel/save.test.c
+++ b/src/kernel/save.test.c
@@ -59,8 +59,8 @@ static void test_readwrite_unit(CuTest * tc)
     int fno;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    f = test_create_faction(0);
+    r = test_create_region(0, 0, NULL);
+    f = test_create_faction(NULL);
     fno = f->no;
     u = test_create_unit(f, r);
     unit_setname(u, "  Hodor  ");
@@ -77,8 +77,8 @@ static void test_readwrite_unit(CuTest * tc)
     
     data.strm.api->rewind(data.strm.handle);
     free_gamedata();
-    f = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
     renumber_faction(f, fno);
     gamedata_init(&data, &store, RELEASE_VERSION);
     u = read_unit(&data);
@@ -101,7 +101,7 @@ static void test_readwrite_faction(CuTest * tc)
     faction *f;
 
     test_setup();
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     free(f->name);
     f->name = str_strdup("  Hodor  ");
     CuAssertStrEquals(tc, "  Hodor  ", f->name);
@@ -131,7 +131,7 @@ static void test_readwrite_region(CuTest * tc)
     const char * lipsum = "Lorem ipsum dolor sit amet";
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     free(r->land->name);
     r->land->name = str_strdup("  Hodor  ");
     CuAssertStrEquals(tc, "  Hodor  ", r->land->name);
@@ -163,8 +163,8 @@ static void test_readwrite_building(CuTest * tc)
     region *r;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    b = test_create_building(r, 0);
+    r = test_create_region(0, 0, NULL);
+    b = test_create_building(r, NULL);
     free(b->name);
     b->name = str_strdup("  Hodor  ");
     CuAssertStrEquals(tc, "  Hodor  ", b->name);
@@ -174,7 +174,7 @@ static void test_readwrite_building(CuTest * tc)
     
     data.strm.api->rewind(data.strm.handle);
     free_gamedata();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     gamedata_init(&data, &store, RELEASE_VERSION);
     b = read_building(&data);
     CuAssertPtrNotNull(tc, b);
@@ -196,8 +196,8 @@ static void test_readwrite_ship(CuTest * tc)
     region *r;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    sh = test_create_ship(r, 0);
+    r = test_create_region(0, 0, NULL);
+    sh = test_create_ship(r, NULL);
     free(sh->name);
     sh->name = str_strdup("  Hodor  ");
     CuAssertStrEquals(tc, "  Hodor  ", sh->name);
@@ -207,7 +207,7 @@ static void test_readwrite_ship(CuTest * tc)
     
     data.strm.api->rewind(data.strm.handle);
     free_gamedata();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     gamedata_init(&data, &store, RELEASE_VERSION);
     sh = read_ship(&data);
     CuAssertPtrNotNull(tc, sh);
@@ -259,13 +259,13 @@ static void test_readwrite_dead_faction_group(CuTest *tc) {
     gamedata_init(&data, &store, RELEASE_VERSION);
 
     test_setup();
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     fno = f->no;
     CuAssertPtrEquals(tc, f, factions);
     CuAssertPtrEquals(tc, 0, f->next);
-    f2 = test_create_faction(0);
+    f2 = test_create_faction(NULL);
     CuAssertPtrEquals(tc, f2, factions->next);
-    u = test_create_unit(f2, test_create_region(0, 0, 0));
+    u = test_create_unit(f2, test_create_region(0, 0, NULL));
     CuAssertPtrNotNull(tc, u);
     g = join_group(u, "group");
     CuAssertPtrNotNull(tc, g);
@@ -305,8 +305,8 @@ static void test_readwrite_dead_faction_regionowner(CuTest *tc) {
     gamedata_init(&data, &store, RELEASE_VERSION);
 
     config_set("rules.region_owners", "1");
-    f = test_create_faction(0);
-    test_create_unit(f, r = test_create_region(0, 0, 0));
+    f = test_create_faction(NULL);
+    test_create_unit(f, r = test_create_region(0, 0, NULL));
     region_set_owner(r, f, 0);
     destroyfaction(&factions);
     CuAssertTrue(tc, !f->_alive);
@@ -335,9 +335,9 @@ static void test_readwrite_dead_faction_changefaction(CuTest *tc) {
     unit * u;
 
     test_setup();
-    f = test_create_faction(0);
-    f2 = test_create_faction(0);
-    u = test_create_unit(f2, r = test_create_region(0, 0, 0));
+    f = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
+    u = test_create_unit(f2, r = test_create_region(0, 0, NULL));
     tr = trigger_changefaction(u, f);
     add_trigger(&u->attribs, "timer", trigger_timeout(10, tr));
     CuAssertPtrNotNull(tc, a_find(u->attribs, &at_eventhandler));
@@ -372,9 +372,9 @@ static void test_readwrite_dead_faction_createunit(CuTest *tc) {
     unit * u;
 
     test_setup();
-    f = test_create_faction(0);
-    f2 = test_create_faction(0);
-    u = test_create_unit(f2, r = test_create_region(0, 0, 0));
+    f = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
+    u = test_create_unit(f2, r = test_create_region(0, 0, NULL));
     tr = trigger_createunit(r, f, f->race, 1);
     add_trigger(&u->attribs, "timer", trigger_timeout(10, tr));
     CuAssertPtrNotNull(tc, a_find(u->attribs, &at_eventhandler));
@@ -406,7 +406,7 @@ static void test_read_password(CuTest *tc) {
     faction *f;
 
     test_setup();
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     faction_setpassword(f, password_encode("secret", PASSWORD_DEFAULT));
     mstream_init(&data.strm);
     gamedata_init(&data, &store, RELEASE_VERSION);
@@ -430,7 +430,7 @@ static void test_read_password_external(CuTest *tc) {
     if (remove(pwfile) != 0) {
         errno = 0;
     }
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     faction_setpassword(f, password_encode("secret", PASSWORD_DEFAULT));
     CuAssertPtrNotNull(tc, f->_password);
     mstream_init(&data.strm);
diff --git a/src/kernel/ship.test.c b/src/kernel/ship.test.c
index f36ce28e2..69766276c 100644
--- a/src/kernel/ship.test.c
+++ b/src/kernel/ship.test.c
@@ -393,7 +393,7 @@ static void test_crew_skill(CuTest *tc) {
     test_setup();
     test_create_world();
     r = test_create_region(0, 0, NULL);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     assert(r && f);
     sh = test_create_ship(r, st_find("boat"));
     for (i = 0; i != 4; ++i) {
@@ -410,7 +410,7 @@ static ship *setup_ship(void) {
     ship_type *stype;
 
     config_set("movement.shipspeed.skillbonus", "0");
-    r = test_create_region(0, 0, test_create_terrain("ocean", 0));
+    r = test_create_ocean(0, 0);
     stype = test_create_shiptype("longboat");
     stype->cptskill = 1;
     stype->sumskill = 10;
@@ -421,7 +421,7 @@ static ship *setup_ship(void) {
 }
 
 static void setup_crew(ship *sh, struct faction *f, unit **cap, unit **crew) {
-    if (!f) f = test_create_faction(0);
+    if (!f) f = test_create_faction(NULL);
     assert(cap);
     assert(crew);
     *cap = test_create_unit(f, sh->region);
@@ -606,7 +606,7 @@ static void test_shipspeed_max_range(CuTest *tc) {
     setup_crew(sh, 0, &cap, &crew);
     config_set("movement.shipspeed.skillbonus", "5");
     r = sh->region;
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     assert(r && f);
     stype = st_get_or_create(sh->type->_name);
 
diff --git a/src/kernel/spell.test.c b/src/kernel/spell.test.c
index 7307e22a1..5502069d1 100644
--- a/src/kernel/spell.test.c
+++ b/src/kernel/spell.test.c
@@ -33,6 +33,7 @@ static void test_create_duplicate_spell(CuTest * tc)
     strlist *sl = 0;
 
     test_setup();
+    test_inject_messagetypes();
     test_log_stderr(0); /* suppress the "duplicate spell" error message */
     log = test_log_start(LOG_CPERROR, &sl);
 
diff --git a/src/kernel/unit.test.c b/src/kernel/unit.test.c
index 5694fb79d..9391e7012 100644
--- a/src/kernel/unit.test.c
+++ b/src/kernel/unit.test.c
@@ -232,7 +232,7 @@ static void test_skillmod(CuTest *tc) {
     attrib *a;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     set_level(u, SK_ARMORER, 5);
     CuAssertIntEquals(tc, 5, effskill(u, SK_ARMORER, 0));
 
@@ -259,7 +259,7 @@ static void test_skill_hunger(CuTest *tc) {
     unit *u;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     set_level(u, SK_ARMORER, 6);
     set_level(u, SK_SAILING, 6);
     fset(u, UFL_HUNGER);
@@ -277,8 +277,8 @@ static void test_skill_familiar(CuTest *tc) {
     test_setup();
 
     /* setup two units */
-    mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    fam = test_create_unit(mag->faction, test_create_region(0, 0, 0));
+    mag = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    fam = test_create_unit(mag->faction, test_create_region(0, 0, NULL));
     set_level(fam, SK_PERCEPTION, 6);
     CuAssertIntEquals(tc, 6, effskill(fam, SK_PERCEPTION, 0));
     set_level(mag, SK_PERCEPTION, 6);
@@ -303,8 +303,8 @@ static void test_inside_building(CuTest *tc) {
     building *b;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    b = test_create_building(u->region, 0);
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    b = test_create_building(u->region, NULL);
 
     b->size = 1;
     scale_number(u, 1);
@@ -327,7 +327,7 @@ static void test_skills(CuTest *tc) {
     unit *u;
     skill *sv;
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     sv = add_skill(u, SK_ALCHEMY);
     CuAssertPtrNotNull(tc, sv);
     CuAssertPtrEquals(tc, sv, u->skills);
@@ -368,7 +368,7 @@ static void test_limited_skills(CuTest *tc) {
     unit *u;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     CuAssertIntEquals(tc, false, has_limited_skills(u));
     set_level(u, SK_ENTERTAINMENT, 1);
     CuAssertIntEquals(tc, false, has_limited_skills(u));
@@ -395,7 +395,7 @@ static void test_unit_description(CuTest *tc) {
     test_setup();
     lang = test_create_locale();
     rc = test_create_race("hodor");
-    u = test_create_unit(test_create_faction(rc), test_create_region(0,0,0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
 
     CuAssertPtrEquals(tc, 0, u->display);
     CuAssertStrEquals(tc, 0, u_description(u, lang));
@@ -421,8 +421,8 @@ static void test_remove_unit(CuTest *tc) {
     test_setup();
     init_resources();
     rtype = get_resourcetype(R_SILVER);
-    r = test_create_region(0, 0, 0);
-    f = test_create_faction(0);
+    r = test_create_region(0, 0, NULL);
+    f = test_create_faction(NULL);
     u2 = test_create_unit(f, r);
     u1 = test_create_unit(f, r);
     CuAssertPtrEquals(tc, u1, f->units);
@@ -466,7 +466,7 @@ static void test_renumber_unit(CuTest *tc) {
     unit *u1, *u2;
 
     test_setup();
-    u1 = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u1 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     u2 = test_create_unit(u1->faction, u1->region);
     rng_init(0);
     renumber_unit(u1, 0);
@@ -487,7 +487,7 @@ static void test_name_unit(CuTest *tc) {
 
     test_setup();
     rc = test_create_race("skeleton");
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     rc->name_unit = gen_name;
     name_unit(u);
     CuAssertStrEquals(tc, "Hodor", unit_getname(u));
diff --git a/src/laws.test.c b/src/laws.test.c
index aca84710f..5edde187d 100644
--- a/src/laws.test.c
+++ b/src/laws.test.c
@@ -39,7 +39,7 @@ static void test_new_building_can_be_renamed(CuTest * tc)
 
     test_setup();
     test_create_locale();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
 
     b = test_create_building(r, NULL);
     CuAssertTrue(tc, !renamed_building(b));
@@ -57,7 +57,7 @@ static void test_rename_building(CuTest * tc)
     test_setup();
     test_create_locale();
     btype = test_create_buildingtype("castle");
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     b = new_building(btype, r, default_locale);
     f = test_create_faction(NULL);
     u = test_create_unit(f, r);
@@ -80,7 +80,7 @@ static void test_rename_building_twice(CuTest * tc)
     test_setup();
     test_create_locale();
     btype = test_create_buildingtype("castle");
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     b = new_building(btype, r, default_locale);
     f = test_create_faction(NULL);
     u = test_create_unit(f, r);
@@ -105,11 +105,11 @@ static void test_contact(CuTest * tc)
     test_setup();
     test_create_locale();
     btype = test_create_buildingtype("castle");
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     b = new_building(btype, r, default_locale);
-    u1 = test_create_unit(test_create_faction(0), r);
-    u2 = test_create_unit(test_create_faction(0), r);
-    u3 = test_create_unit(test_create_faction(0), r);
+    u1 = test_create_unit(test_create_faction(NULL), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
+    u3 = test_create_unit(test_create_faction(NULL), r);
     set_level(u3, SK_PERCEPTION, 2);
     usetsiege(u3, b);
     b->besieged = 1;
@@ -134,7 +134,7 @@ static void test_enter_building(CuTest * tc)
 
     test_setup();
     test_create_locale();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     rc = test_create_race("human");
     u = test_create_unit(test_create_faction(rc), r);
     b = test_create_building(r, test_create_buildingtype("castle"));
@@ -210,7 +210,7 @@ static void test_display_cmd(CuTest *tc) {
 
     test_setup();
     r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     assert(r && f);
     u = test_create_unit(f, r);
     assert(u);
@@ -255,9 +255,9 @@ static void test_force_leave_buildings(CuTest *tc) {
     region *r;
     unit *u1, *u2, *u3;
     building * b;
-    message *msg;
 
     test_setup();
+    mt_register(mt_new_va("force_leave_building", "unit:unit", "owner:unit", "building:building", NULL));
     r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
     u1 = test_create_unit(test_create_faction(NULL), r);
     u2 = test_create_unit(u1->faction, r);
@@ -271,8 +271,7 @@ static void test_force_leave_buildings(CuTest *tc) {
     CuAssertPtrEquals_Msg(tc, "owner should not be forced to leave", b, u1->building);
     CuAssertPtrEquals_Msg(tc, "same faction should not be forced to leave", b, u2->building);
     CuAssertPtrEquals_Msg(tc, "non-allies should be forced to leave", NULL, u3->building);
-    msg = test_get_last_message(u3->faction->msgs);
-    CuAssertStrEquals(tc, "force_leave_building", test_get_messagetype(msg));
+    CuAssertPtrNotNull(tc, test_find_messagetype(u3->faction->msgs, "force_leave_building"));
 
     u_set_building(u3, b);
     al = ally_add(&u1->faction->allies, u3->faction);
@@ -286,9 +285,9 @@ static void test_force_leave_ships(CuTest *tc) {
     region *r;
     unit *u1, *u2;
     ship *sh;
-    message *msg;
 
     test_setup();
+    mt_register(mt_new_va("force_leave_ship", "unit:unit", "owner:unit", "ship:ship", NULL));
     r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
     u1 = test_create_unit(test_create_faction(NULL), r);
     u2 = test_create_unit(test_create_faction(NULL), r);
@@ -298,8 +297,7 @@ static void test_force_leave_ships(CuTest *tc) {
     ship_set_owner(u1);
     force_leave(r, NULL);
     CuAssertPtrEquals_Msg(tc, "non-allies should be forced to leave", NULL, u2->ship);
-    msg = test_get_last_message(u2->faction->msgs);
-    CuAssertStrEquals(tc, "force_leave_ship", test_get_messagetype(msg));
+    CuAssertPtrNotNull(tc, test_find_messagetype(u2->faction->msgs, "force_leave_ship"));
     test_teardown();
 }
 
@@ -816,7 +814,7 @@ static void test_reserve_self(CuTest *tc) {
     rtype = get_resourcetype(R_SILVER);
     assert(rtype && rtype->itype);
     f = test_create_faction(NULL);
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     assert(r && f);
     u1 = test_create_unit(f, r);
     u2 = test_create_unit(f, r);
@@ -877,6 +875,7 @@ static void test_luck_message(CuTest *tc) {
     attrib *a;
 
     test_setup();
+    mt_register(mt_new_va("peasantluck_success", "births:int", NULL));
     setup_terrains(tc);
     r = test_create_region(0, 0, NULL);
     rsetpeasants(r, 1);
@@ -901,8 +900,10 @@ static unit * setup_name_cmd(void) {
     faction *f;
 
     test_setup();
-    f = test_create_faction(0);
-    return test_create_unit(f, test_create_region(0, 0, 0));
+    mt_register(mt_new_va("renamed_building_seen", "renamer:unit", "region:region", "building:building", NULL));
+    mt_register(mt_new_va("renamed_building_notseen", "region:region", "building:building", NULL));
+    f = test_create_faction(NULL);
+    return test_create_unit(f, test_create_region(0, 0, NULL));
 }
 
 static void test_name_unit(CuTest *tc) {
@@ -935,7 +936,7 @@ static void test_name_region(CuTest *tc) {
     f = u->faction;
 
     ord = create_order(K_NAME, f->locale, "%s Hodor", LOC(f->locale, parameters[P_REGION]));
-    u_set_building(u, test_create_building(u->region, 0));
+    u_set_building(u, test_create_building(u->region, NULL));
     name_cmd(u, ord);
     CuAssertStrEquals(tc, "Hodor", u->region->land->name);
     free_order(ord);
@@ -954,7 +955,7 @@ static void test_name_building(CuTest *tc) {
     faction *f;
 
     u = setup_name_cmd();
-    u->building = test_create_building(u->region, 0);
+    u->building = test_create_building(u->region, NULL);
     f = u->faction;
     uo = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     u_set_building(uo, u->building);
@@ -998,7 +999,7 @@ static void test_name_ship(CuTest *tc) {
     faction *f;
 
     u = setup_name_cmd();
-    u->ship = test_create_ship(u->region, 0);
+    u->ship = test_create_ship(u->region, NULL);
     f = u->faction;
     uo = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     u_set_ship(uo, u->ship);
@@ -1038,7 +1039,7 @@ static void test_long_order_normal(CuTest *tc) {
     order *ord;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     fset(u, UFL_MOVED);
     fset(u, UFL_LONGACTION);
     unit_addorder(u, ord = create_order(K_MOVE, u->faction->locale, 0));
@@ -1056,7 +1057,7 @@ static void test_long_order_none(CuTest *tc) {
     /* TODO: write more tests */
     unit *u;
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     update_long_order(u);
     CuAssertPtrEquals(tc, 0, u->thisorder);
     CuAssertPtrEquals(tc, 0, u->orders);
@@ -1068,9 +1069,9 @@ static void test_long_order_cast(CuTest *tc) {
     /* TODO: write more tests */
     unit *u;
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    unit_addorder(u, create_order(K_CAST, u->faction->locale, 0));
-    unit_addorder(u, create_order(K_CAST, u->faction->locale, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    unit_addorder(u, create_order(K_CAST, u->faction->locale, NULL));
+    unit_addorder(u, create_order(K_CAST, u->faction->locale, NULL));
     update_long_order(u);
     CuAssertPtrEquals(tc, 0, u->thisorder);
     CuAssertPtrNotNull(tc, u->orders);
@@ -1082,10 +1083,10 @@ static void test_long_order_buy_sell(CuTest *tc) {
     /* TODO: write more tests */
     unit *u;
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
-    unit_addorder(u, create_order(K_SELL, u->faction->locale, 0));
-    unit_addorder(u, create_order(K_SELL, u->faction->locale, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    unit_addorder(u, create_order(K_BUY, u->faction->locale, NULL));
+    unit_addorder(u, create_order(K_SELL, u->faction->locale, NULL));
+    unit_addorder(u, create_order(K_SELL, u->faction->locale, NULL));
     update_long_order(u);
     CuAssertPtrEquals(tc, 0, u->thisorder);
     CuAssertPtrNotNull(tc, u->orders);
@@ -1097,9 +1098,9 @@ static void test_long_order_multi_long(CuTest *tc) {
     /* TODO: write more tests */
     unit *u;
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    unit_addorder(u, create_order(K_MOVE, u->faction->locale, 0));
-    unit_addorder(u, create_order(K_DESTROY, u->faction->locale, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    unit_addorder(u, create_order(K_MOVE, u->faction->locale, NULL));
+    unit_addorder(u, create_order(K_DESTROY, u->faction->locale, NULL));
     update_long_order(u);
     CuAssertPtrNotNull(tc, u->thisorder);
     CuAssertPtrNotNull(tc, u->orders);
@@ -1111,7 +1112,7 @@ static void test_long_order_multi_buy(CuTest *tc) {
     /* TODO: write more tests */
     unit *u;
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
     unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
     update_long_order(u);
@@ -1125,7 +1126,7 @@ static void test_long_order_multi_sell(CuTest *tc) {
     /* TODO: write more tests */
     unit *u;
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     unit_addorder(u, create_order(K_SELL, u->faction->locale, 0));
     unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
     unit_addorder(u, create_order(K_SELL, u->faction->locale, 0));
@@ -1140,7 +1141,7 @@ static void test_long_order_buy_cast(CuTest *tc) {
     /* TODO: write more tests */
     unit *u;
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
     unit_addorder(u, create_order(K_CAST, u->faction->locale, 0));
     update_long_order(u);
@@ -1154,7 +1155,7 @@ static void test_long_order_hungry(CuTest *tc) {
     unit *u;
     test_setup();
     config_set("hunger.long", "1");
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     fset(u, UFL_HUNGER);
     unit_addorder(u, create_order(K_MOVE, u->faction->locale, 0));
     unit_addorder(u, create_order(K_DESTROY, u->faction->locale, 0));
@@ -1172,7 +1173,7 @@ static void test_ally_cmd_errors(CuTest *tc) {
     order *ord;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     fid = u->faction->no + 1;
     CuAssertPtrEquals(tc, 0, findfaction(fid));
 
@@ -1191,7 +1192,7 @@ static void test_name_cmd(CuTest *tc) {
     order *ord;
 
     test_setup();
-    u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
     setalliance(f, al = makealliance(42, ""));
 
     ord = create_order(K_NAME, f->locale, "%s '  Ho\tdor  '", LOC(f->locale, parameters[P_UNIT]));
@@ -1205,13 +1206,13 @@ static void test_name_cmd(CuTest *tc) {
     free_order(ord);
 
     ord = create_order(K_NAME, f->locale, "%s '  Ho\tdor  '", LOC(f->locale, parameters[P_SHIP]));
-    u->ship = test_create_ship(u->region, 0);
+    u->ship = test_create_ship(u->region, NULL);
     name_cmd(u, ord);
     CuAssertStrEquals(tc, "Hodor", u->ship->name);
     free_order(ord);
     
     ord = create_order(K_NAME, f->locale, "%s '  Ho\tdor  '", LOC(f->locale, parameters[P_BUILDING]));
-    u_set_building(u, test_create_building(u->region, 0));
+    u_set_building(u, test_create_building(u->region, NULL));
     name_cmd(u, ord);
     CuAssertStrEquals(tc, "Hodor", u->building->name);
     free_order(ord);
@@ -1235,9 +1236,9 @@ static void test_name_cmd_2274(CuTest *tc) {
     region *r;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    u1 = test_create_unit(test_create_faction(0), r);
-    u2 = test_create_unit(test_create_faction(0), r);
+    r = test_create_region(0, 0, NULL);
+    u1 = test_create_unit(test_create_faction(NULL), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
     u3 = test_create_unit(u2->faction, r);
     u_set_building(u1, test_create_building(r, NULL));
     u1->building->size = 10;
@@ -1266,8 +1267,8 @@ static void test_ally_cmd(CuTest *tc) {
     order *ord;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    f = test_create_faction(0);
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    f = test_create_faction(NULL);
 
     ord = create_order(K_ALLY, f->locale, "%s", itoa36(f->no));
     ally_cmd(u, ord);
@@ -1299,9 +1300,12 @@ static void test_ally_cmd(CuTest *tc) {
 static void test_nmr_warnings(CuTest *tc) {
     faction *f1, *f2;
     test_setup();
+    mt_register(mt_new_va("nmr_warning", NULL));
+    mt_register(mt_new_va("nmr_warning_final", NULL));
+    mt_register(mt_new_va("warn_dropout", "faction:faction", "turn:int", NULL));
     config_set("nmr.timeout", "3");
-    f1 = test_create_faction(0);
-    f2 = test_create_faction(0);
+    f1 = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
     f2->age = 2;
     f2->lastorders = 1;
     turn = 3;
@@ -1320,8 +1324,11 @@ static unit * setup_mail_cmd(void) {
     faction *f;
     
     test_setup();
-    f = test_create_faction(0);
-    return test_create_unit(f, test_create_region(0, 0, 0));
+    mt_register(mt_new_va("regionmessage", "region:region", "sender:unit", "string:string", NULL));
+    mt_register(mt_new_va("unitmessage", "region:region", "sender:unit", "string:string", "unit:unit", NULL));
+    mt_register(mt_new_va("mail_result", "message:string", "unit:unit", NULL));
+    f = test_create_faction(NULL);
+    return test_create_unit(f, test_create_region(0, 0, NULL));
 }
 
 static void test_mail_unit(CuTest *tc) {
@@ -1436,6 +1443,7 @@ static void test_show_without_item(CuTest *tc)
     struct locale *loc;
 
     test_setup();
+    mt_register(mt_new_va("displayitem", "weight:int", "item:resource", "description:string", NULL));
 
     loc = get_or_create_locale("de");
     locale_setstring(loc, parameters[P_ANY], "ALLE");
@@ -1480,7 +1488,7 @@ static void test_show_race(CuTest *tc) {
 
     test_setup();
 
-    mt_register(mt_new_va("msg_event", "string:string", 0));
+    mt_register(mt_new_va("msg_event", "string:string", NULL));
     test_create_race("human");
     rc = test_create_race("elf");
 
@@ -1490,7 +1498,7 @@ static void test_show_race(CuTest *tc) {
     locale_setstring(loc, "race::human_p", "Menschen");
     locale_setstring(loc, "race::human", "Mensch");
     init_locale(loc);
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     u->faction->locale = loc;
 
     ord = create_order(K_RESHOW, loc, "Mensch");
@@ -1520,8 +1528,8 @@ static void test_show_both(CuTest *tc) {
     message * msg;
 
     test_setup();
-    mt_register(mt_new_va("msg_event", "string:string", 0));
-    mt_register(mt_new_va("displayitem", "weight:int", "item:resource", "description:string", 0));
+    mt_register(mt_new_va("msg_event", "string:string", NULL));
+    mt_register(mt_new_va("displayitem", "weight:int", "item:resource", "description:string", NULL));
     rc = test_create_race("elf");
     test_create_itemtype("elvenhorse");
 
@@ -1536,7 +1544,7 @@ static void test_show_both(CuTest *tc) {
     CuAssertPtrNotNull(tc, finditemtype("elf", loc));
     CuAssertPtrNotNull(tc, findrace("elf", loc));
 
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     u->faction->locale = loc;
     i_change(&u->items, finditemtype("elfenpferd", loc), 1);
     ord = create_order(K_RESHOW, loc, "Elf");
@@ -1559,7 +1567,7 @@ static void test_immigration(CuTest * tc)
     double inject[] = { 1 };
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
 
     rsetpeasants(r, 0);
     config_set("rules.economy.repopulate_maximum", 0);
@@ -1590,11 +1598,10 @@ static void test_demon_hunger(CuTest * tc)
     race *rc;
     faction *f;
     unit *u;
-    message* msg;
 
     test_setup();
     init_resources();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     rc = test_create_race("demon");
     f = test_create_faction(rc);
     u = test_create_unit(f, r);
@@ -1617,8 +1624,7 @@ static void test_demon_hunger(CuTest * tc)
     get_food(r);
 
     CuAssertIntEquals(tc, 10, i_get(u->items, rtype->itype));
-    msg = test_get_last_message(u->faction->msgs);
-    CuAssertStrEquals(tc, "malnourish", test_get_messagetype(msg));
+    CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "malnourish"));
 
     test_teardown();
 }
@@ -1629,7 +1635,7 @@ static void test_armedmen(CuTest *tc) {
     item_type *it_sword;
     weapon_type *wtype;
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     it_sword = test_create_itemtype("sword");
     wtype = new_weapontype(it_sword, 0, frac_make(1, 2), 0, 0, 0, 0, SK_MELEE);
     CuAssertIntEquals(tc, 0, armedmen(u, false));
@@ -1658,8 +1664,8 @@ static void test_cansee(CuTest *tc) {
     unit *u, *u2;
     
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    u2 = test_create_unit(test_create_faction(0), u->region);
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    u2 = test_create_unit(test_create_faction(NULL), u->region);
     
     CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
 
@@ -1677,8 +1683,8 @@ static void test_cansee_ring(CuTest *tc) {
     item_type *itype[2];
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    u2 = test_create_unit(test_create_faction(0), u->region);
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    u2 = test_create_unit(test_create_faction(NULL), u->region);
     scale_number(u2, 2);
 
     itype[0] = test_create_itemtype("roi");
@@ -1710,8 +1716,8 @@ static void test_cansee_sphere(CuTest *tc) {
     item_type *itype[2];
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    u2 = test_create_unit(test_create_faction(0), u->region);
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    u2 = test_create_unit(test_create_faction(NULL), u->region);
 
     itype[0] = test_create_itemtype("sphereofinv");
     itype[1] = test_create_itemtype("aots");
diff --git a/src/lighthouse.test.c b/src/lighthouse.test.c
index 5b7d11c40..e0c57ec1a 100644
--- a/src/lighthouse.test.c
+++ b/src/lighthouse.test.c
@@ -21,10 +21,10 @@ static void test_lighthouse_range(CuTest * tc)
     building *b;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     test_create_region(1, 0, 0);
-    u1 = test_create_unit(test_create_faction(0), r);
-    u2 = test_create_unit(test_create_faction(0), r);
+    u1 = test_create_unit(test_create_faction(NULL), r);
+    u2 = test_create_unit(test_create_faction(NULL), r);
     b = test_create_building(r, test_create_buildingtype("lighthouse"));
     CuAssertIntEquals(tc, 0, lighthouse_range(b, NULL, NULL));
     CuAssertIntEquals(tc, 0, lighthouse_range(b, u1->faction, NULL));
diff --git a/src/magic.test.c b/src/magic.test.c
index 760558688..f4606b75a 100644
--- a/src/magic.test.c
+++ b/src/magic.test.c
@@ -36,7 +36,7 @@ void test_updatespells(CuTest * tc)
     test_setup();
     test_create_race("human");
 
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     sp = create_spell("testspell");
     CuAssertPtrNotNull(tc, sp);
 
@@ -108,7 +108,7 @@ void test_pay_spell(CuTest * tc)
     test_setup();
     init_resources();
     r = test_create_region(0, 0, NULL);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     u = test_create_unit(f, r);
     CuAssertPtrNotNull(tc, u);
 
@@ -142,7 +142,7 @@ void test_pay_spell_failure(CuTest * tc)
     test_setup();
     init_resources();
     r = test_create_region(0, 0, NULL);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     u = test_create_unit(f, r);
     CuAssertPtrNotNull(tc, u);
 
@@ -178,8 +178,8 @@ void test_getspell_unit(CuTest * tc)
     struct locale * lang;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
-    f = test_create_faction(0);
+    r = test_create_region(0, 0, NULL);
+    f = test_create_faction(NULL);
     u = test_create_unit(f, r);
     create_mage(u, M_GRAY);
     enable_skill(SK_MAGIC, true);
@@ -207,7 +207,7 @@ void test_getspell_faction(CuTest * tc)
 
     test_setup();
     r = test_create_region(0, 0, NULL);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     f->magiegebiet = M_TYBIED;
     u = test_create_unit(f, r);
     create_mage(u, f->magiegebiet);
@@ -238,7 +238,7 @@ void test_getspell_school(CuTest * tc)
 
     test_setup();
     r = test_create_region(0, 0, NULL);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     f->magiegebiet = M_TYBIED;
     u = test_create_unit(f, r);
     create_mage(u, f->magiegebiet);
@@ -268,7 +268,7 @@ void test_set_pre_combatspell(CuTest * tc)
 
     test_setup();
     r = test_create_region(0, 0, NULL);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     f->magiegebiet = M_TYBIED;
     u = test_create_unit(f, r);
     enable_skill(SK_MAGIC, true);
@@ -300,7 +300,7 @@ void test_set_main_combatspell(CuTest * tc)
 
     test_setup();
     r = test_create_region(0, 0, NULL);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     f->magiegebiet = M_TYBIED;
     u = test_create_unit(f, r);
     enable_skill(SK_MAGIC, true);
@@ -332,7 +332,7 @@ void test_set_post_combatspell(CuTest * tc)
 
     test_setup();
     r = test_create_region(0, 0, NULL);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     f->magiegebiet = M_TYBIED;
     u = test_create_unit(f, r);
     enable_skill(SK_MAGIC, true);
@@ -363,7 +363,7 @@ void test_hasspell(CuTest * tc)
 
     test_setup();
     r = test_create_region(0, 0, NULL);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     f->magiegebiet = M_TYBIED;
     u = test_create_unit(f, r);
     enable_skill(SK_MAGIC, true);
@@ -404,7 +404,7 @@ void test_multi_cast(CuTest *tc) {
     locale_setstring(lang, mkname("spell", sp->sname), "Feuerball");
     CuAssertStrEquals(tc, "Feuerball", spell_name(sp, lang));
 
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     set_level(u, SK_MAGIC, 10);
     unit_add_spell(u, 0, sp, 1);
     CuAssertPtrEquals(tc, sp, unit_getspell(u, "Feuerball", lang));
@@ -425,7 +425,7 @@ static void test_magic_resistance(CuTest *tc) {
 
     test_setup();
     rc = test_create_race("human");
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     CuAssertTrue(tc, frac_equal(rc->magres, magic_resistance(u)));
     rc->magres = frac_one;
     CuAssert(tc, "magic resistance is capped at 0.9", frac_equal(magic_resistance(u), frac_make(9, 10)));
@@ -444,7 +444,7 @@ static void test_max_spellpoints(CuTest *tc) {
 
     test_setup();
     rc = test_create_race("human");
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u));
     rc->maxaura = 100;
     CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u));
@@ -487,7 +487,7 @@ static void test_is_mage(CuTest *tc) {
     sc_mage *mage;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     CuAssertPtrEquals(tc, NULL, get_mage(u));
     CuAssertTrue(tc, !is_mage(u));
     set_level(u, SK_MAGIC, 1);
@@ -504,7 +504,7 @@ static void test_get_mage(CuTest *tc) {
     sc_mage *mage;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     CuAssertPtrEquals(tc, NULL, get_mage(u));
     CuAssertPtrEquals(tc, NULL, get_mage_depr(u));
     CuAssertPtrNotNull(tc, mage = create_mage(u, M_CERDDOR));
@@ -521,8 +521,8 @@ static void test_familiar_set(CuTest *tc) {
 
     test_setup();
 
-    mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    fam = test_create_unit(mag->faction, test_create_region(0, 0, 0));
+    mag = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    fam = test_create_unit(mag->faction, test_create_region(0, 0, NULL));
     CuAssertPtrEquals(tc, NULL, get_familiar(mag));
     CuAssertPtrEquals(tc, NULL, get_familiar_mage(fam));
     CuAssertPtrEquals(tc, NULL, a_find(mag->attribs, &at_skillmod));
@@ -541,8 +541,8 @@ static void test_familiar_age(CuTest *tc) {
 
     test_setup();
 
-    mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    fam = test_create_unit(mag->faction, test_create_region(0, 0, 0));
+    mag = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    fam = test_create_unit(mag->faction, test_create_region(0, 0, NULL));
     set_familiar(mag, fam);
     CuAssertPtrEquals(tc, fam, get_familiar(mag));
     CuAssertPtrEquals(tc, mag, get_familiar_mage(fam));
@@ -575,8 +575,8 @@ static void test_familiar_equip(CuTest *tc) {
     equipment_setskill(eq, SK_ENTERTAINMENT, "5");
     equipment_addspell(eq, sp->sname, 1);
 
-    mag = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    u = test_create_unit(mag->faction, test_create_region(0, 0, 0));
+    mag = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    u = test_create_unit(mag->faction, test_create_region(0, 0, NULL));
     set_familiar(mag, u);
     create_newfamiliar(mag, u);
     CuAssertIntEquals(tc, 1, i_get(u->items, itype));
diff --git a/src/main.c b/src/main.c
index 1ad91589d..f50f65472 100644
--- a/src/main.c
+++ b/src/main.c
@@ -22,8 +22,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 #include <kernel/config.h>
 #include <kernel/database.h>
-#include <kernel/version.h>
+#include <kernel/messages.h>
 #include <kernel/save.h>
+#include <kernel/version.h>
 
 #include <util/filereader.h>
 #include <util/language.h>
@@ -305,6 +306,7 @@ int main(int argc, char **argv)
     lua_State *L;
     dictionary *d = 0;
     setup_signal_handler();
+    message_handle_missing(MESSAGE_MISSING_REPLACE);
     /* parse arguments again, to override ini file */
     err = parse_args(argc, argv);
     if (err != 0) {
diff --git a/src/market.test.c b/src/market.test.c
index 29a9d8d4b..1fc8307fa 100644
--- a/src/market.test.c
+++ b/src/market.test.c
@@ -12,6 +12,7 @@
 #include <kernel/unit.h>
 
 #include <util/language.h>
+#include <util/message.h>
 
 #include <CuTest.h>
 #include <tests.h>
@@ -32,6 +33,7 @@ static void test_market_curse(CuTest * tc)
     building_type *btype;
 
     test_setup();
+    mt_register(mt_new_va("buyamount", "unit:unit", "amount:int", "resource:resource", NULL));
 
     htype = test_create_itemtype("herb");
     htype->flags |= ITF_HERB;
@@ -66,7 +68,7 @@ static void test_market_curse(CuTest * tc)
     b->flags |= BLD_MAINTAINED;
     b->size = b->type->maxsize;
 
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     u = test_create_unit(f, r);
     u_set_building(u, b);
 
diff --git a/src/monsters.test.c b/src/monsters.test.c
index f03915774..32efc6a4c 100644
--- a/src/monsters.test.c
+++ b/src/monsters.test.c
@@ -48,6 +48,7 @@ static void create_monsters(unit **up, unit **um) {
     region *r;
     faction *fp, *fm;
 
+    mt_register(mt_new_va("dragon_growl", "dragon:unit", "number:int", "target:region", "growl:string", NULL));
     test_create_horse();
     default_locale = test_create_locale();
     fp = test_create_faction(NULL);
@@ -60,7 +61,7 @@ static void create_monsters(unit **up, unit **um) {
 
     test_create_region(-1, 0, test_create_terrain("ocean", SEA_REGION | SWIM_INTO | FLY_INTO));
     test_create_region(1, 0, 0);
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
 
     *up = test_create_unit(fp, r);
     unit_setid(*up, 1);
@@ -215,7 +216,7 @@ static void test_dragon_moves(CuTest * tc)
     plan_monsters(m->faction);
     CuAssertPtrNotNull(tc, find_order("move east", m));
 
-    mt_register(mt_new_va("dragon_growl", "dragon:unit", "number:int", "target:region", "growl:string", 0));
+    mt_register(mt_new_va("dragon_growl", "dragon:unit", "number:int", "target:region", "growl:string", NULL));
 
     random_growl(m, findregion(1, 0), 3);
 
@@ -258,8 +259,8 @@ static void test_spawn_seaserpent(CuTest *tc) {
     test_setup();
     rc = test_create_race("seaserpent");
     rc->flags |= RCF_NPC;
-    r = test_create_region(0, 0, 0);
-    f = test_create_faction(0);
+    r = test_create_region(0, 0, NULL);
+    f = test_create_faction(NULL);
     u = spawn_seaserpent(r, f);
     CuAssertPtrNotNull(tc, u);
     CuAssertPtrEquals(tc, 0, u->_name);
diff --git a/src/move.test.c b/src/move.test.c
index ff65fa823..3aca0c2ab 100644
--- a/src/move.test.c
+++ b/src/move.test.c
@@ -27,6 +27,11 @@
 #include <tests.h>
 #include <assert.h>
 
+static void setup_move(void) {
+    mt_register(mt_new_va("travel", "unit:unit", "start:region", "end:region", "mode:int", "regions:regions", NULL));
+    mt_register(mt_new_va("moveblocked", "unit:unit", "direction:int", NULL));
+}
+
 static void test_ship_not_allowed_in_coast(CuTest * tc)
 {
     region *r1, *r2;
@@ -70,13 +75,13 @@ static void setup_harbor(move_fixture *mf) {
     ttype = test_create_terrain("glacier", LAND_REGION | ARCTIC_REGION | WALK_INTO);
     btype = test_create_buildingtype("harbour");
 
-    sh = test_create_ship(0, 0);
+    sh = test_create_ship(0, NULL);
     r = test_create_region(0, 0, ttype);
 
     b = test_create_building(r, btype);
     b->flags |= BLD_MAINTAINED;
 
-    u = test_create_unit(test_create_faction(0), r);
+    u = test_create_unit(test_create_faction(NULL), r);
     u->ship = sh;
     ship_set_owner(u);
 
@@ -104,7 +109,7 @@ static void test_ship_blocked_by_harbormaster(CuTest * tc) {
     test_setup();
     setup_harbor(&mf);
 
-    u = test_create_unit(test_create_faction(0), mf.r);
+    u = test_create_unit(test_create_faction(NULL), mf.r);
     u->building = mf.b;
     building_set_owner(u);
 
@@ -119,7 +124,7 @@ static void test_ship_has_harbormaster_contact(CuTest * tc) {
     test_setup();
     setup_harbor(&mf);
 
-    u = test_create_unit(test_create_faction(0), mf.r);
+    u = test_create_unit(test_create_faction(NULL), mf.r);
     u->building = mf.b;
     building_set_owner(u);
     usetcontact(mf.b->_owner, mf.sh->_owner);
@@ -151,7 +156,7 @@ static void test_ship_has_harbormaster_ally(CuTest * tc) {
     test_setup();
     setup_harbor(&mf);
 
-    u = test_create_unit(test_create_faction(0), mf.r);
+    u = test_create_unit(test_create_faction(NULL), mf.r);
     u->building = mf.b;
     building_set_owner(u);
     al = ally_add(&u->faction->allies, mf.u->faction);
@@ -214,8 +219,8 @@ static void test_ship_trails(CuTest *tc) {
     r1 = test_create_region(0, 0, otype);
     r2 = test_create_region(1, 0, otype);
     r3 = test_create_region(2, 0, otype);
-    sh = test_create_ship(r1, 0);
-    move_ship(sh, r1, r3, 0);
+    sh = test_create_ship(r1, NULL);
+    move_ship(sh, r1, r3, NULL);
     CuAssertPtrEquals(tc, r3, sh->region);
     CuAssertPtrEquals(tc, sh, r3->ships);
     CuAssertPtrEquals(tc, 0, r1->ships);
@@ -240,9 +245,9 @@ static void test_age_trails(CuTest *tc) {
     ship *sh;
 
     test_setup();
-    r1 = test_create_region(0, 0, 0);
-    r2 = test_create_region(1, 0, 0);
-    sh = test_create_ship(r1, 0);
+    r1 = test_create_region(0, 0, NULL);
+    r2 = test_create_region(1, 0, NULL);
+    sh = test_create_ship(r1, NULL);
     add_regionlist(&route, r1);
     add_regionlist(&route, r2);
     move_ship(sh, r1, r2, route);
@@ -274,11 +279,15 @@ void setup_drift (struct drift_fixture *fix) {
     fix->st_boat->cabins = 20000;
 
     test_create_ocean(0, 0);
-    fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r = test_create_ocean(-1, 0));
+    fix->u = test_create_unit(fix->f = test_create_faction(NULL), fix->r = test_create_ocean(-1, 0));
     assert(fix->r && fix->u && fix->f);
     set_level(fix->u, SK_SAILING, fix->st_boat->sumskill);
     u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat));
     assert(fix->sh);
+
+    mt_register(mt_new_va("ship_drift", "ship:ship", "dir:int", NULL));
+    mt_register(mt_new_va("shipsink", "ship:ship", NULL));
+    mt_register(mt_new_va("massive_overload", "ship:ship", NULL));
 }
 
 static void test_ship_no_overload(CuTest *tc) {
@@ -450,7 +459,7 @@ static void test_follow_ship_msg(CuTest * tc) {
     test_setup();
     init_resources();
 
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     r = test_create_plain(0, 0);
     test_create_ocean(-1, 1); /* D_NORTHWEST */
 
@@ -473,7 +482,7 @@ static void test_follow_ship_msg(CuTest * tc) {
     td->dir = D_NORTHWEST;
     td->age = 2;
 
-    mt_register(mt_new_va("error18", "unit:unit", "region:region", "command:order", 0));
+    mt_register(mt_new_va("error18", "unit:unit", "region:region", "command:order", NULL));
 
     init_order_depr(ord);
     getstrtoken();
@@ -566,6 +575,7 @@ static void test_route_cycle(CuTest *tc) {
     char buffer[32];
 
     test_setup();
+    setup_move();
     test_create_region(1, 0, NULL);
     r = test_create_region(2, 0, NULL);
     lang = test_create_locale();
@@ -577,6 +587,7 @@ static void test_route_cycle(CuTest *tc) {
     CuAssertStrEquals(tc, "route WEST EAST NW", get_command(u->orders, lang, buffer, sizeof(buffer)));
     init_order(u->orders, u->faction->locale);
     move_cmd(u, u->orders);
+    CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "moveblocked"));
     CuAssertIntEquals(tc, 1, u->region->x);
     CuAssertStrEquals(tc, "route east nw west", get_command(u->orders, lang, buffer, sizeof(buffer)));
     test_teardown();
@@ -589,6 +600,7 @@ static void test_route_pause(CuTest *tc) {
     char buffer[32];
 
     test_setup();
+    setup_move();
     test_create_region(1, 0, NULL);
     r = test_create_region(2, 0, NULL);
     lang = test_create_locale();
diff --git a/src/names.test.c b/src/names.test.c
index ae9fe639a..ec4526d71 100644
--- a/src/names.test.c
+++ b/src/names.test.c
@@ -27,7 +27,7 @@ static void test_names(CuTest * tc)
     CuAssertPtrNotNull(tc, get_function("name_dracoid"));
     default_locale = test_create_locale();
     rc = test_create_race("undead");
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     locale_setstring(default_locale, "undead_name_0", "Graue");
     locale_setstring(default_locale, "undead_postfix_0", "Kobolde");
     CuAssertPtrNotNull(tc, rc->name_unit);
@@ -50,7 +50,7 @@ static void test_monster_names(CuTest *tc) {
     rc = test_create_race("irongolem");
     f = test_create_faction(rc);
     f->flags |= FFL_NPC;
-    u = test_create_unit(f, test_create_region(0, 0, 0));
+    u = test_create_unit(f, test_create_region(0, 0, NULL));
     unit_setname(u, "Hodor");
     CuAssertPtrNotNull(tc, u->_name);
     name_unit(u);
diff --git a/src/orderfile.test.c b/src/orderfile.test.c
index b39aa31bc..500c68fdf 100644
--- a/src/orderfile.test.c
+++ b/src/orderfile.test.c
@@ -4,6 +4,7 @@
 #include "orderfile.h"
 
 #include <kernel/faction.h>
+#include <util/message.h>
 
 #include <CuTest.h>
 #include <tests.h>
@@ -62,6 +63,8 @@ static void test_faction_password_bad(CuTest *tc) {
     const char *orders[] = { "ERESSEA 1 password", NULL };
 
     test_setup();
+    mt_register(mt_new_va("wrongpasswd", "password:string", NULL));
+
     f = test_create_faction(NULL);
     renumber_faction(f, 1);
     CuAssertIntEquals(tc, 1, f->no);
diff --git a/src/piracy.test.c b/src/piracy.test.c
index db31df48d..22f5ccc5a 100644
--- a/src/piracy.test.c
+++ b/src/piracy.test.c
@@ -12,6 +12,7 @@
 
 #include <util/base36.h>
 #include <util/language.h>
+#include <util/message.h>
 
 #include <CuTest.h>
 #include <tests.h>
@@ -28,6 +29,13 @@ static void setup_piracy(void) {
     test_create_terrain("ocean", SEA_REGION);
     st_boat = test_create_shiptype("boat");
     st_boat->cargo = 1000;
+
+    mt_register(mt_new_va("piratenovictim", "ship:ship", "unit:unit", "region:region", NULL));
+    mt_register(mt_new_va("piratesawvictim", "ship:ship", "unit:unit", "region:region", "dir:int", NULL));
+    mt_register(mt_new_va("shipsail", "ship:ship", "from:region", "to:region", NULL));
+    mt_register(mt_new_va("shipfly", "ship:ship", "from:region", "to:region", NULL));
+    mt_register(mt_new_va("shipnoshore", "ship:ship", "region:region", NULL));
+    mt_register(mt_new_va("travel", "unit:unit", "start:region", "end:region", "mode:int", "regions:regions", NULL));
 }
 
 static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const char *p_shiptype,
@@ -40,7 +48,7 @@ static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const cha
     setup_piracy();
     vterrain = get_or_create_terrain("terrain1");
     fset(vterrain, v_r_flags);
-    *victim = test_create_unit(test_create_faction(0), test_create_region(1, 0, vterrain));
+    *victim = test_create_unit(test_create_faction(NULL), test_create_region(1, 0, vterrain));
     assert(*victim);
 
     if (v_shiptype) {
@@ -52,7 +60,7 @@ static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const cha
         st_boat->coasts[1] = 0;
     }
 
-    *pirate = create_unit(test_create_region(0, 0, get_or_create_terrain("terrain2")), f = test_create_faction(0), 1, rc = rc_get_or_create("pirate"), 0, 0, 0);
+    *pirate = create_unit(test_create_region(0, 0, get_or_create_terrain("terrain2")), f = test_create_faction(NULL), 1, rc = rc_get_or_create("pirate"), 0, 0, 0);
     fset(rc, p_rc_flags);
     assert(f && *pirate);
 
@@ -81,10 +89,10 @@ static void test_piracy_cmd(CuTest * tc) {
 
     t_ocean = get_or_create_terrain("ocean");
     st_boat = st_get_or_create("boat");
-    u2 = test_create_unit(test_create_faction(0), test_create_region(1, 0, t_ocean));
+    u2 = test_create_unit(test_create_faction(NULL), test_create_region(1, 0, t_ocean));
     assert(u2);
     u_set_ship(u2, test_create_ship(u2->region, st_boat));
-    u = test_create_unit(f = test_create_faction(0), r = test_create_region(0, 0, t_ocean));
+    u = test_create_unit(f = test_create_faction(NULL), r = test_create_region(0, 0, t_ocean));
     assert(f && u);
     set_level(u, SK_SAILING, st_boat->sumskill);
     u_set_ship(u, test_create_ship(u->region, st_boat));
@@ -183,14 +191,14 @@ static void test_piracy_cmd_land_to_land(CuTest * tc) {
 
     /* create a target: */
     r = test_create_region(0, 0, t_plain);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     u = test_create_unit(f, r);
     u->ship = test_create_ship(r, stype);
     target = f->no;
 
     /* create a pirate: */
     r = test_create_region(1, 0, t_plain);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     u = test_create_unit(f, r);
     u->ship = test_create_ship(r, stype);
     set_level(u, SK_SAILING, u->ship->type->sumskill);
diff --git a/src/renumber.test.c b/src/renumber.test.c
index e8433b828..dfac52e8c 100644
--- a/src/renumber.test.c
+++ b/src/renumber.test.c
@@ -9,6 +9,7 @@
 #include <kernel/order.h>
 #include <util/base36.h>
 #include <util/language.h>
+#include <util/message.h>
 
 #include <stddef.h>
 #include <CuTest.h>
@@ -19,7 +20,7 @@ static void test_renumber_faction(CuTest *tc) {
     const struct locale *lang;
 
     test_setup_ex(tc);
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     no = u->faction->no;
     uno = (no > 1) ? no - 1 : no + 1;
     lang = u->faction->locale;
@@ -37,8 +38,9 @@ static void test_renumber_faction_duplicate(CuTest *tc) {
     const struct locale *lang;
 
     test_setup_ex(tc);
-    f2 = test_create_faction(0);
-    u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
+    mt_register(mt_new_va("renumber_inuse", "id:int", NULL));
+    f2 = test_create_faction(NULL);
+    u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
     no = f->no;
     lang = f->locale;
     u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_FACTION]), itoa36(f2->no));
@@ -55,8 +57,8 @@ static void test_renumber_building(CuTest *tc) {
     const struct locale *lang;
 
     test_setup_ex(tc);
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    u->building = test_create_building(u->region, 0);
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    u->building = test_create_building(u->region, NULL);
     no = u->building->no;
     uno = (no > 1) ? no - 1 : no + 1;
     lang = u->faction->locale;
@@ -73,10 +75,10 @@ static void test_renumber_building_duplicate(CuTest *tc) {
     const struct locale *lang;
 
     test_setup_ex(tc);
-    u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
-    u->building = test_create_building(u->region, 0);
+    u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
+    u->building = test_create_building(u->region, NULL);
     uno = u->building->no;
-    u->building = test_create_building(u->region, 0);
+    u->building = test_create_building(u->region, NULL);
     no = u->building->no;
     lang = f->locale;
     u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_BUILDING]), itoa36(uno));
@@ -92,8 +94,8 @@ static void test_renumber_ship(CuTest *tc) {
     const struct locale *lang;
 
     test_setup_ex(tc);
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    u->ship = test_create_ship(u->region, 0);
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    u->ship = test_create_ship(u->region, NULL);
     no = u->ship->no;
     uno = (no > 1) ? no - 1 : no + 1;
     lang = u->faction->locale;
@@ -109,8 +111,8 @@ static void test_renumber_ship_twice(CuTest *tc) {
     const struct locale *lang;
 
     test_setup_ex(tc);
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
-    u->ship = test_create_ship(u->region, 0);
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+    u->ship = test_create_ship(u->region, NULL);
     no = u->ship->no;
     uno = (no > 1) ? no - 1 : no + 1;
     lang = u->faction->locale;
@@ -131,10 +133,10 @@ static void test_renumber_ship_duplicate(CuTest *tc) {
     const struct locale *lang;
 
     test_setup_ex(tc);
-    u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
-    u->ship = test_create_ship(u->region, 0);
+    u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
+    u->ship = test_create_ship(u->region, NULL);
     uno = u->ship->no;
-    u->ship = test_create_ship(u->region, 0);
+    u->ship = test_create_ship(u->region, NULL);
     no = u->ship->no;
     lang = f->locale;
     u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(uno));
@@ -150,7 +152,7 @@ static void test_renumber_unit(CuTest *tc) {
     const struct locale *lang;
 
     test_setup_ex(tc);
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     no = u->no;
     uno = (no > 1) ? no - 1 : no + 1;
     lang = u->faction->locale;
@@ -168,7 +170,7 @@ static void test_renumber_unit_duplicate(CuTest *tc) {
     const struct locale *lang;
 
     test_setup_ex(tc);
-    u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
     no = u->no;
     u2 = test_create_unit(f, u->region);
     lang = f->locale;
@@ -187,7 +189,7 @@ static void test_renumber_unit_limit(CuTest *tc) {
     const struct locale *lang;
 
     test_setup_ex(tc);
-    u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
     no = u->no;
     lang = f->locale;
     u->thisorder = create_order(K_NUMBER, lang, "%s 10000", LOC(lang, parameters[P_UNIT]));
@@ -205,7 +207,7 @@ static void test_renumber_unit_invalid(CuTest *tc) {
     const struct locale *lang;
 
     test_setup_ex(tc);
-    u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
     no = u->no;
     lang = f->locale;
     u->thisorder = create_order(K_NUMBER, lang, "%s TEMP", LOC(lang, parameters[P_UNIT]));
diff --git a/src/report.test.c b/src/report.test.c
index 191374c1e..77bb6dca6 100644
--- a/src/report.test.c
+++ b/src/report.test.c
@@ -95,7 +95,7 @@ static void test_report_region(CuTest *tc) {
     locale_setstring(lang, "see_travel", "durchgereist");
 
     mstream_init(&out);
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     add_resource(r, 1, 135, 10, rt_stone);
     CuAssertIntEquals(tc, 1, r->resources->level);
     r->land->peasants = 5;
@@ -105,7 +105,7 @@ static void test_report_region(CuTest *tc) {
     rsettrees(r, 1, 2);
     rsettrees(r, 2, 3);
     region_setname(r, "Hodor");
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     f->locale = lang;
     u = test_create_unit(f, r);
     set_level(u, SK_QUARRYING, 1);
@@ -155,11 +155,11 @@ static void test_report_travelthru(CuTest *tc) {
     lang = get_or_create_locale("de");
     locale_setstring(lang, "travelthru_header", "Durchreise: ");
     mstream_init(&out);
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     r->flags |= RF_TRAVELUNIT;
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     f->locale = lang;
-    u = test_create_unit(f, test_create_region(0, 1, 0));
+    u = test_create_unit(f, test_create_region(0, 1, NULL));
     unit_setname(u, "Hodor");
     unit_setid(u, 1);
 
diff --git a/src/reports.test.c b/src/reports.test.c
index e618d709c..ca0f98f57 100644
--- a/src/reports.test.c
+++ b/src/reports.test.c
@@ -54,7 +54,7 @@ static void test_reorder_units(CuTest * tc)
     r = test_create_region(0, 0, NULL);
     b = test_create_building(r, NULL);
     s = test_create_ship(r, NULL);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
 
     u0 = test_create_unit(f, r);
     u_set_ship(u0, s);
@@ -184,11 +184,11 @@ static void test_bufunit_fstealth(CuTest *tc) {
     lang = get_or_create_locale("de");
     locale_setstring(lang, "status_aggressive", "aggressive");
     locale_setstring(lang, "anonymous", "anonymous");
-    f1 = test_create_faction(0);
+    f1 = test_create_faction(NULL);
     f1->locale = lang;
-    f2 = test_create_faction(0);
+    f2 = test_create_faction(NULL);
     f2->locale = lang;
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     u = test_create_unit(f1, r);
     faction_setname(f1, "UFO");
     renumber_faction(f1, 1);
@@ -271,7 +271,7 @@ static void test_bufunit(CuTest *tc) {
     locale_setstring(lang, "skill::alchemy", "Alchemie");
     locale_setstring(lang, "status_aggressive", "aggressiv");
     init_skills(lang);
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     u->faction->locale = lang;
     faction_setname(u->faction, "UFO");
     renumber_faction(u->faction, 1);
@@ -289,7 +289,7 @@ static void test_bufunit(CuTest *tc) {
     bufunit(u->faction, u, 0, 0, buffer, sizeof(buffer));
     CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressiv, Talente: Alchemie 2, Segeln 1.", buffer);
 
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     f->locale = get_or_create_locale("de");
     bufunit(f, u, 0, 0, buffer, sizeof(buffer));
     CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buffer);
@@ -334,7 +334,7 @@ static void test_newbie_password_message(CuTest *tc) {
     report_context ctx;
     faction *f;
     test_setup();
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     f->age = 5;
     f->flags = 0;
     prepare_report(&ctx, f);
@@ -355,9 +355,9 @@ static void test_prepare_travelthru(CuTest *tc) {
     unit *u;
 
     test_setup();
-    f = test_create_faction(0);
-    f2 = test_create_faction(0);
-    r1 = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
+    r1 = test_create_region(0, 0, NULL);
     r2 = test_create_region(1, 0, 0);
     r3 = test_create_region(3, 0, 0);
     test_create_unit(f2, r1);
@@ -391,10 +391,10 @@ static void test_get_addresses(CuTest *tc) {
     region *r;
 
     test_setup();
-    f = test_create_faction(0);
-    f1 = test_create_faction(0);
-    f2 = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    f1 = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
     test_create_unit(f, r);
     test_create_unit(f1, r);
     test_create_unit(f2, r);
@@ -418,10 +418,10 @@ static void test_get_addresses_fstealth(CuTest *tc) {
     unit *u;
 
     test_setup();
-    f = test_create_faction(0);
-    f1 = test_create_faction(0);
-    f2 = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    f1 = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
     test_create_unit(f, r);
     u = test_create_unit(f1, r);
     set_factionstealth(u, f2);
@@ -446,10 +446,10 @@ static void test_get_addresses_travelthru(CuTest *tc) {
     unit *u;
 
     test_setup();
-    f = test_create_faction(0);
-    f1 = test_create_faction(0);
-    f2 = test_create_faction(0);
-    r1 = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    f1 = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
+    r1 = test_create_region(0, 0, NULL);
     r2 = test_create_region(1, 0, 0);
     u = test_create_unit(f, r2);
     travelthru_add(r1, u);
@@ -480,7 +480,7 @@ void test_prepare_lighthouse_capacity(CuTest *tc) {
     report_context ctx;
 
     test_setup();
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     t_ocean = test_create_terrain("ocean", SEA_REGION);
     t_plain = test_create_terrain("plain", LAND_REGION);
     btype = test_create_buildingtype("lighthouse");
@@ -491,7 +491,7 @@ void test_prepare_lighthouse_capacity(CuTest *tc) {
     b->flags |= BLD_MAINTAINED;
     b->size = 10;
     update_lighthouse(b);
-    u1 = test_create_unit(test_create_faction(0), r1);
+    u1 = test_create_unit(test_create_faction(NULL), r1);
     u1->number = 4;
     u1->building = b;
     set_level(u1, SK_PERCEPTION, 3);
@@ -539,7 +539,7 @@ static void test_prepare_lighthouse(CuTest *tc) {
     test_setup();
     t_ocean = test_create_terrain("ocean", SEA_REGION);
     t_plain = test_create_terrain("plain", LAND_REGION);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     r1 = test_create_region(0, 0, t_plain);
     r2 = test_create_region(1, 0, t_ocean);
     r3 = test_create_region(2, 0, t_ocean);
@@ -581,7 +581,7 @@ static void test_prepare_lighthouse_owners(CuTest *tc)
     config_set("rules.region_owners", "1");
     t_ocean = test_create_terrain("ocean", SEA_REGION);
     t_plain = test_create_terrain("plain", LAND_REGION);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     r1 = test_create_region(0, 0, t_plain);
     r2 = test_create_region(1, 0, t_ocean);
     r3 = test_create_region(2, 0, t_ocean);
@@ -592,7 +592,7 @@ static void test_prepare_lighthouse_owners(CuTest *tc)
     b->size = 10;
     update_lighthouse(b);
     u = test_create_unit(f, r1);
-    u = test_create_unit(test_create_faction(0), r1);
+    u = test_create_unit(test_create_faction(NULL), r1);
     u->building = b;
     region_set_owner(b->region, f, 0);
     CuAssertIntEquals(tc, 2, lighthouse_range(b, NULL, NULL));
@@ -612,8 +612,8 @@ static void test_prepare_report(CuTest *tc) {
     region *r;
 
     test_setup();
-    f = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
 
     prepare_report(&ctx, f);
     CuAssertPtrEquals(tc, 0, ctx.first);
@@ -645,8 +645,8 @@ static void test_seen_neighbours(CuTest *tc) {
     region *r1, *r2;
 
     test_setup();
-    f = test_create_faction(0);
-    r1 = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    r1 = test_create_region(0, 0, NULL);
     r2 = test_create_region(1, 0, 0);
 
     test_create_unit(f, r1);
@@ -666,8 +666,8 @@ static void test_seen_travelthru(CuTest *tc) {
     region *r1, *r2, *r3;
 
     test_setup();
-    f = test_create_faction(0);
-    r1 = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    r1 = test_create_region(0, 0, NULL);
     r2 = test_create_region(1, 0, 0);
     r3 = test_create_region(2, 0, 0);
 
@@ -692,7 +692,7 @@ static void test_region_distance_max(CuTest *tc) {
     region *result[64];
     int x, y;
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     for (x=-3;x<=3;++x) {
         for (y = -3; y <= 3; ++y) {
             if (x != 0 || y != 0) {
@@ -711,7 +711,7 @@ static void test_region_distance(CuTest *tc) {
     region *r;
     region *result[8];
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     CuAssertIntEquals(tc, 1, get_regions_distance_arr(r, 0, result, 8));
     CuAssertPtrEquals(tc, r, result[0]);
     CuAssertIntEquals(tc, 1, get_regions_distance_arr(r, 1, result, 8));
@@ -727,7 +727,7 @@ static void test_region_distance_ql(CuTest *tc) {
     region *r;
     selist *ql;
     test_setup();
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     ql = get_regions_distance(r, 0);
     CuAssertIntEquals(tc, 1, selist_length(ql));
     CuAssertPtrEquals(tc, r, selist_get(ql, 0));
@@ -747,8 +747,8 @@ static void test_report_far_vision(CuTest *tc) {
     faction *f;
     region *r1, *r2;
     test_setup();
-    f = test_create_faction(0);
-    r1 = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    r1 = test_create_region(0, 0, NULL);
     test_create_unit(f, r1);
     r2 = test_create_region(10, 0, 0);
     set_observer(r2, f, 10, 2);
@@ -788,6 +788,7 @@ static void test_insect_warnings(CuTest *tc) {
 
     /* OBS: in unit tests, get_gamedate always returns season = 0 */
     test_setup();
+    test_inject_messagetypes();
     f = test_create_faction(test_create_race("insect"));
 
     gd.turn = 0;
@@ -805,6 +806,7 @@ static void test_newbie_warning(CuTest *tc) {
     faction *f;
 
     test_setup();
+    test_inject_messagetypes();
     f = test_create_faction(test_create_race("insect"));
     config_set_int("NewbieImmunity", 3);
 
@@ -826,8 +828,8 @@ static void test_cansee_spell(CuTest *tc) {
     faction *f;
 
     test_setup();
-    f = test_create_faction(0);
-    u2 = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    f = test_create_faction(NULL);
+    u2 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
 
     CuAssertTrue(tc, cansee(f, u2->region, u2, 0));
     CuAssertTrue(tc, visible_unit(u2, f, 0, seen_spell));
diff --git a/src/spells.test.c b/src/spells.test.c
index 497feb26f..e151e7680 100644
--- a/src/spells.test.c
+++ b/src/spells.test.c
@@ -12,8 +12,9 @@
 #include <kernel/region.h>
 #include <kernel/spell.h>
 #include <kernel/unit.h>
-#include <util/language.h>
 #include <util/attrib.h>
+#include <util/language.h>
+#include <util/message.h>
 #include <spells/regioncurse.h>
 
 #include <attributes/attributes.h>
@@ -26,6 +27,10 @@
 #include <string.h>
 #include <assert.h>
 
+static void setup_spells(void) {
+    test_inject_messagetypes();
+}
+
 static void test_good_dreams(CuTest *tc) {
     struct region *r;
     struct faction *f1, *f2;
@@ -35,10 +40,11 @@ static void test_good_dreams(CuTest *tc) {
     curse *curse;
     
     test_setup();
+    setup_spells();
     test_create_world();
     r = findregion(0, 0);
-    f1 = test_create_faction(0);
-    f2 = test_create_faction(0);
+    f1 = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
     u1 = test_create_unit(f1, r);
     u2 = test_create_unit(f2, r);
 
@@ -64,9 +70,10 @@ static void test_dreams(CuTest *tc) {
     castorder co;
 
     test_setup();
+    setup_spells();
     r = test_create_region(0, 0, NULL);
-    f1 = test_create_faction(0);
-    f2 = test_create_faction(0);
+    f1 = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
     u1 = test_create_unit(f1, r);
     u2 = test_create_unit(f2, r);
 
@@ -91,10 +98,11 @@ static void test_bad_dreams(CuTest *tc) {
     curse *curse;
     
     test_setup();
+    setup_spells();
     test_create_world();
     r = findregion(0, 0);
-    f1 = test_create_faction(0);
-    f2 = test_create_faction(0);
+    f1 = test_create_faction(NULL);
+    f2 = test_create_faction(NULL);
     u1 = test_create_unit(f1, r);
     u2 = test_create_unit(f2, r);
 
@@ -121,10 +129,13 @@ static void test_view_reality(CuTest *tc) {
     castorder co;
 
     test_setup();
+    setup_spells();
+    mt_register(mt_new_va("spell_astral_only", "unit:unit", "region:region", "command:order", NULL));
+    mt_register(mt_new_va("viewreality_effect", "unit:unit", NULL));
     r = test_create_region(0, 0, NULL);
     ra = test_create_region(real2tp(r->x), real2tp(r->y), NULL);
     ra->_plane = get_astralplane();
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     u = test_create_unit(f, r);
 
     test_create_castorder(&co, u, 10, 10., 0, NULL);
@@ -152,8 +163,9 @@ static void test_watch_region(CuTest *tc) {
     region *r;
     faction *f;
     test_setup();
-    r = test_create_region(0, 0, 0);
-    f = test_create_faction(0);
+    setup_spells();
+    r = test_create_region(0, 0, NULL);
+    f = test_create_faction(NULL);
     CuAssertIntEquals(tc, -1, get_observer(r, f));
     set_observer(r, f, 0, 2);
     CuAssertIntEquals(tc, 0, get_observer(r, f));
diff --git a/src/spells/flyingship.test.c b/src/spells/flyingship.test.c
index d602ddc07..3459adcd3 100644
--- a/src/spells/flyingship.test.c
+++ b/src/spells/flyingship.test.c
@@ -7,6 +7,8 @@
 #include <kernel/unit.h>
 #include <kernel/ship.h>
 
+#include <util/message.h>
+
 #include <magic.h>
 
 #include <CuTest.h>
@@ -27,12 +29,13 @@ static void test_flyingship(CuTest * tc)
     ship *sh1, *sh2;
 
     test_setup();
+    mt_register(mt_new_va("flying_ship_result", "mage:unit", "ship:ship", NULL));
 
     par.param = &par_data_ptr;
     par_data.typ = SPP_SHIP;
     par_data.flag = 0;
 
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     f = test_create_faction(test_create_race("human"));
     u = test_create_unit(f, r);
 
diff --git a/src/spells/magicresistance.c b/src/spells/magicresistance.c
index 6f2ec49ec..f5cbb55dd 100644
--- a/src/spells/magicresistance.c
+++ b/src/spells/magicresistance.c
@@ -10,14 +10,14 @@ static struct message *cinfo_magicresistance(const void *obj, objtype_t typ, con
     if (typ == TYP_UNIT) {
         if (self != 0) {
             const struct unit *u = (const struct unit *)obj;
-            return msg_message(mkname("curseinfo", "magicresistance_unit"), "unit id", u,
+            return msg_message("magicresistance_unit", "unit id", u,
                 c->no);
         }
         return NULL;
     }
     if (typ == TYP_BUILDING) {
         const struct building *b = (const struct building *)obj;
-        return msg_message(mkname("curseinfo", "magicresistance_building"), "id building", c->no, b);
+        return msg_message("magicresistance_building", "id building", c->no, b);
     }
     return 0;
 }
diff --git a/src/spells/magicresistance.test.c b/src/spells/magicresistance.test.c
index 3af64b1ce..ccce0216c 100644
--- a/src/spells/magicresistance.test.c
+++ b/src/spells/magicresistance.test.c
@@ -29,6 +29,7 @@ static void test_magicresistance_unit(CuTest *tc) {
     curse *c;
 
     test_setup();
+    mt_register(mt_new_va("magicresistance_unit", "unit:unit", "id:int", NULL));
     r = test_create_plain(0, 0);
     f1 = test_create_faction(NULL);
     u1 = test_create_unit(f1, r);
@@ -41,7 +42,7 @@ static void test_magicresistance_unit(CuTest *tc) {
     CuAssertPtrEquals(tc, (void *)&at_curse, (void *)u2->attribs->type);
     msg = c->type->curseinfo(u2, TYP_UNIT, c, 1);
     CuAssertPtrNotNull(tc, msg);
-    CuAssertStrEquals(tc, "curseinfo::magicresistance_unit", test_get_messagetype(msg));
+    CuAssertStrEquals(tc, "magicresistance_unit", test_get_messagetype(msg));
     msg_release(msg);
 
     test_teardown();
@@ -56,6 +57,7 @@ static void test_magicresistance_building(CuTest *tc) {
     curse *c;
 
     test_setup();
+    mt_register(mt_new_va("magicresistance_building", "building:building", "id:int", NULL));
     r = test_create_plain(0, 0);
     f1 = test_create_faction(NULL);
     u1 = test_create_unit(f1, r);
@@ -67,7 +69,7 @@ static void test_magicresistance_building(CuTest *tc) {
     CuAssertPtrEquals(tc, (void *)&at_curse, (void *)b1->attribs->type);
     msg = c->type->curseinfo(b1, TYP_BUILDING, c, 1);
     CuAssertPtrNotNull(tc, msg);
-    CuAssertStrEquals(tc, "curseinfo::magicresistance_building", test_get_messagetype(msg));
+    CuAssertStrEquals(tc, "magicresistance_building", test_get_messagetype(msg));
     msg_release(msg);
     test_teardown();
 }
diff --git a/src/spy.test.c b/src/spy.test.c
index e8675a406..79108f03b 100644
--- a/src/spy.test.c
+++ b/src/spy.test.c
@@ -33,15 +33,31 @@ typedef struct {
 } spy_fixture;
 
 static void setup_spy(spy_fixture *fix) {
-    test_setup();
-    fix->r = test_create_region(0, 0, NULL);
-    fix->spy = test_create_unit(test_create_faction(NULL), fix->r);
-    fix->victim = test_create_unit(test_create_faction(NULL), fix->r);
+    mt_register(mt_new_va("spyreport", "spy:unit", "target:unit", "status:int", NULL));
+    mt_register(mt_new_va("spyreport_mage", "spy:unit", "target:unit", "type:int", NULL));
+    mt_register(mt_new_va("spyreport_faction", "spy:unit", "target:unit", "faction:faction", NULL));
+    mt_register(mt_new_va("spyreport_skills", "spy:unit", "target:unit", "skills:string", NULL));
+    mt_register(mt_new_va("spyreport_items", "spy:unit", "target:unit", "items:items", NULL));
+    mt_register(mt_new_va("destroy_ship_0", "unit:unit", "ship:ship", NULL));
+    mt_register(mt_new_va("destroy_ship_1", "unit:unit", "ship:ship", NULL));
+    mt_register(mt_new_va("destroy_ship_2", "unit:unit", "ship:ship", NULL));
+    mt_register(mt_new_va("destroy_ship_3", "ship:ship", NULL));
+    mt_register(mt_new_va("destroy_ship_4", "ship:ship", NULL));
+    mt_register(mt_new_va("sink_msg", "ship:ship", "region:region", NULL));
+    mt_register(mt_new_va("sink_lost_msg", "unit:unit", "region:region", "dead:int", NULL));
+    mt_register(mt_new_va("sink_saved_msg", "unit:unit", "region:region", NULL));
+
+    if (fix) {
+        fix->r = test_create_region(0, 0, NULL);
+        fix->spy = test_create_unit(test_create_faction(NULL), fix->r);
+        fix->victim = test_create_unit(test_create_faction(NULL), fix->r);
+    }
 }
 
 static void test_simple_spy_message(CuTest *tc) {
     spy_fixture fix;
 
+    test_setup();
     setup_spy(&fix);
 
     spy_message(0, fix.spy, fix.victim);
@@ -55,6 +71,7 @@ static void test_all_spy_message(CuTest *tc) {
     spy_fixture fix;
     item_type *itype;
 
+    test_setup();
     setup_spy(&fix);
 
     enable_skill(SK_MAGIC, true);
@@ -84,7 +101,8 @@ static void test_sabotage_self(CuTest *tc) {
     order *ord;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    setup_spy(NULL);
+    r = test_create_region(0, 0, NULL);
     assert(r);
     u = test_create_unit(test_create_faction(NULL), r);
     assert(u && u->faction && u->region == r);
@@ -94,6 +112,7 @@ static void test_sabotage_self(CuTest *tc) {
     assert(ord);
     CuAssertIntEquals(tc, 0, sabotage_cmd(u, ord));
     CuAssertPtrEquals(tc, 0, r->ships);
+    CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "sink_msg"));
     free_order(ord);
     test_teardown();
 }
@@ -106,7 +125,9 @@ static void test_sabotage_other_fail(CuTest *tc) {
     message *msg;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    setup_spy(NULL);
+
+    r = test_create_region(0, 0, NULL);
     assert(r);
     u = test_create_unit(test_create_faction(NULL), r);
     u2 = test_create_unit(test_create_faction(NULL), r);
@@ -133,7 +154,7 @@ static void test_setstealth_cmd(CuTest *tc) {
     const struct locale *lang;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     lang = u->faction->locale;
     u->flags = UFL_ANON_FACTION | UFL_SIEGE;
     u->thisorder = create_order(K_SETSTEALTH, lang, "%s %s",
@@ -157,7 +178,7 @@ static void test_setstealth_demon(CuTest *tc) {
     test_setup();
     lang = test_create_locale();
     rc = test_create_race("demon");
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     rc = test_create_race("dwarf");
     init_races(lang);
     u->thisorder = create_order(K_SETSTEALTH, lang, racename(lang, u, rc));
@@ -174,7 +195,7 @@ static void test_setstealth_demon_bad(CuTest *tc) {
     test_setup();
     lang = test_create_locale();
     rc = test_create_race("demon");
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     rc = test_create_race("smurf");
     init_races(lang);
     u->thisorder = create_order(K_SETSTEALTH, lang, racename(lang, u, rc));
@@ -189,7 +210,8 @@ static void test_sabotage_other_success(CuTest *tc) {
     order *ord;
 
     test_setup();
-    r = test_create_region(0, 0, 0);
+    setup_spy(NULL);
+    r = test_create_region(0, 0, NULL);
     assert(r);
     u = test_create_unit(test_create_faction(NULL), r);
     u2 = test_create_unit(test_create_faction(NULL), r);
diff --git a/src/study.test.c b/src/study.test.c
index 3ca0288c2..b89d0ed07 100644
--- a/src/study.test.c
+++ b/src/study.test.c
@@ -57,6 +57,12 @@ typedef struct {
     unit *teachers[2];
 } study_fixture;
 
+static void setup_study(void) {
+    mt_register(mt_new_va("studycost", "unit:unit", "region:region", "cost:int", "skill:int", NULL));
+    mt_register(mt_new_va("teach_teacher", "teacher:unit", "student:unit", "skill:int", "level:int", NULL));
+    mt_register(mt_new_va("teach_student", "teacher:unit", "student:unit", "skill:int", NULL));
+}
+
 static void setup_locale(struct locale *lang) {
     int i;
     for (i = 0; i < MAXSKILLS; ++i) {
@@ -66,7 +72,7 @@ static void setup_locale(struct locale *lang) {
     init_skills(lang);
 }
 
-static void setup_study(study_fixture *fix, skill_t sk) {
+static void setup_teacher(study_fixture *fix, skill_t sk) {
     struct region * r;
     struct faction *f;
     struct locale *lang;
@@ -74,8 +80,8 @@ static void setup_study(study_fixture *fix, skill_t sk) {
     assert(fix);
     test_setup();
     config_set("study.random_progress", "0");
-    r = test_create_region(0, 0, 0);
-    f = test_create_faction(0);
+    r = test_create_region(0, 0, NULL);
+    f = test_create_faction(NULL);
     f->locale = lang = test_create_locale();
     setup_locale(lang);
     fix->u = test_create_unit(f, r);
@@ -96,7 +102,7 @@ static void test_study_no_teacher(CuTest *tc) {
     study_fixture fix;
     skill *sv;
 
-    setup_study(&fix, SK_CROSSBOW);
+    setup_teacher(&fix, SK_CROSSBOW);
     study_cmd(fix.u, fix.u->thisorder);
     CuAssertPtrNotNull(tc, sv = unit_skill(fix.u, SK_CROSSBOW));
     CuAssertIntEquals(tc, 1, sv->level);
@@ -109,7 +115,7 @@ static void test_study_with_teacher(CuTest *tc) {
     study_fixture fix;
     skill *sv;
 
-    setup_study(&fix, SK_CROSSBOW);
+    setup_teacher(&fix, SK_CROSSBOW);
     set_level(fix.teachers[0], SK_CROSSBOW, TEACHDIFFERENCE);
     teach_cmd(fix.teachers[0], fix.teachers[0]->thisorder);
     CuAssertPtrEquals(tc, 0, test_get_last_message(fix.u->faction->msgs));
@@ -124,7 +130,7 @@ static void test_study_with_bad_teacher(CuTest *tc) {
     study_fixture fix;
     skill *sv;
 
-    setup_study(&fix, SK_CROSSBOW);
+    setup_teacher(&fix, SK_CROSSBOW);
     teach_cmd(fix.teachers[0], fix.teachers[0]->thisorder);
     CuAssertPtrNotNull(tc, test_find_messagetype(fix.u->faction->msgs, "teach_asgood"));
     study_cmd(fix.u, fix.u->thisorder);
@@ -144,7 +150,7 @@ static void test_study_bug_2194(CuTest *tc) {
     init_resources();
     loc = test_create_locale();
     setup_locale(loc);
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     scale_number(u, 2);
     set_level(u, SK_CROSSBOW, TEACHDIFFERENCE);
     u->faction->locale = loc;
@@ -197,7 +203,7 @@ static void test_produceexp(CuTest *tc) {
 
     g_tc = tc;
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     scale_number(u, 2);
     config_set("study.produceexp", "20");
     produceexp_ex(u, SK_ALCHEMY, 1, cb_learn_one);
@@ -212,13 +218,13 @@ static void test_academy_building(CuTest *tc) {
     message * msg;
 
     test_setup();
-    mt_register(mt_new_va("teach_asgood", "unit:unit", "region:region", "command:order", "student:unit", 0));
+    mt_register(mt_new_va("teach_asgood", "unit:unit", "region:region", "command:order", "student:unit", NULL));
 
     random_source_inject_constant(0.0);
     init_resources();
     loc = test_create_locale();
     setup_locale(loc);
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     scale_number(u, 2);
     set_level(u, SK_CROSSBOW, TEACHDIFFERENCE);
     u->faction->locale = loc;
@@ -262,15 +268,16 @@ static void test_academy_bonus(CuTest *tc) {
     building * b;
 
     test_setup();
+    setup_study();
 
     random_source_inject_constant(0.0);
     init_resources();
     loc = test_create_locale();
     setup_locale(loc);
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     u->faction->locale = loc;
 
-    u0 = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u0 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     set_level(u, SK_CROSSBOW, TEACHDIFFERENCE);
     set_level(u0, SK_CROSSBOW, TEACHDIFFERENCE);
     
@@ -319,7 +326,7 @@ void test_learn_skill_single(CuTest *tc) {
     skill *sv;
     test_setup();
     config_set("study.random_progress", "0");
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     learn_skill(u, SK_ALCHEMY, STUDYDAYS);
     CuAssertPtrNotNull(tc, sv = u->skills);
     CuAssertIntEquals(tc, SK_ALCHEMY, sv->id);
@@ -338,7 +345,7 @@ void test_learn_skill_multi(CuTest *tc) {
     skill *sv;
     test_setup();
     config_set("study.random_progress", "0");
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     scale_number(u, 10);
     learn_skill(u, SK_ALCHEMY, STUDYDAYS * u->number);
     CuAssertPtrNotNull(tc, sv = u->skills);
@@ -359,7 +366,7 @@ static void test_demon_skillchanges(CuTest *tc) {
     test_setup();
     rc = test_create_race("demon");
     CuAssertPtrEquals(tc, (void *)rc, (void *)get_race(RC_DAEMON));
-    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
     CuAssertPtrNotNull(tc, u);
     set_level(u, SK_CROSSBOW, 1);
     demon_skillchange(u);
@@ -371,7 +378,7 @@ static void test_study_cmd(CuTest *tc) {
     unit *u;
     test_setup();
     init_resources();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
     learn_inject();
     study_cmd(u, u->thisorder);
@@ -389,10 +396,11 @@ static void test_study_magic(CuTest *tc) {
     const struct item_type *itype;
 
     test_setup();
+    setup_study();
     init_resources();
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     lang = f->locale;
-    u = test_create_unit(f, test_create_region(0, 0, 0));
+    u = test_create_unit(f, test_create_region(0, 0, NULL));
     u->thisorder = create_order(K_STUDY, lang, "%s", skillnames[SK_MAGIC]);
     itype = test_create_silver();
 
@@ -421,7 +429,8 @@ static void test_study_cost_magic(CuTest *tc) {
     unit * u;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    setup_study();
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
 
     CuAssertIntEquals(tc, 100, study_cost(u, SK_MAGIC));
     set_level(u, SK_MAGIC, 1);
@@ -444,9 +453,10 @@ static void test_study_cost(CuTest *tc) {
     const struct item_type *itype;
 
     test_setup();
+    setup_study();
 
     itype = test_create_silver();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     scale_number(u, 2);
     u->thisorder = create_order(K_STUDY, u->faction->locale, skillnames[SK_ALCHEMY]);
 
@@ -471,11 +481,12 @@ static void test_teach_magic(CuTest *tc) {
     const struct item_type *itype;
 
     test_setup();
+    setup_study();
     init_resources();
     itype = get_resourcetype(R_SILVER)->itype;
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     f->magiegebiet = M_GWYRRD;
-    u = test_create_unit(f, test_create_region(0, 0, 0));
+    u = test_create_unit(f, test_create_region(0, 0, NULL));
     u->thisorder = create_order(K_STUDY, f->locale, "%s", skillnames[SK_MAGIC]);
     i_change(&u->items, itype, study_cost(u, SK_MAGIC));
     ut = test_create_unit(f, u->region);
@@ -497,7 +508,7 @@ static void test_teach_cmd(CuTest *tc) {
     unit *u, *ut;
     test_setup();
     init_resources();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     scale_number(u, 10);
     u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
     ut = test_create_unit(u->faction, u->region);
@@ -517,7 +528,7 @@ static void test_teach_two(CuTest *tc) {
     unit *u1, *u2, *ut;
     test_setup();
     init_resources();
-    u1 = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u1 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     scale_number(u1, 5);
     u1->thisorder = create_order(K_STUDY, u1->faction->locale, "CROSSBOW");
     u2 = test_create_unit(u1->faction, u1->region);
@@ -547,8 +558,8 @@ static void test_teach_two_skills(CuTest *tc) {
 
     test_setup();
     init_resources();
-    f = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
     u1 = test_create_unit(f, r);
     scale_number(u1, 5);
     u1->thisorder = create_order(K_STUDY, f->locale, "CROSSBOW");
@@ -577,7 +588,7 @@ static void test_teach_one_to_many(CuTest *tc) {
     unit *u, *ut;
     test_setup();
     init_resources();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     scale_number(u, 20);
     u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
     ut = test_create_unit(u->faction, u->region);
@@ -598,7 +609,7 @@ static void test_teach_many_to_one(CuTest *tc) {
 
     test_setup();
     init_resources();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     scale_number(u, 20);
     u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
     u1 = test_create_unit(u->faction, u->region);
@@ -625,14 +636,16 @@ static void test_teach_message(CuTest *tc) {
     teaching_info *teach;
 
     test_setup();
+    mt_register(mt_new_va("teach_teacher", "teacher:unit", "student:unit", "skill:int", "level:int", NULL));
+    mt_register(mt_new_va("teach_student", "teacher:unit", "student:unit", "skill:int", NULL));
     init_resources();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     scale_number(u, 20);
     u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
-    u1 = test_create_unit(test_create_faction(0), u->region);
+    u1 = test_create_unit(test_create_faction(NULL), u->region);
     set_level(u1, SK_CROSSBOW, TEACHDIFFERENCE);
     u1->thisorder = create_order(K_TEACH, u->faction->locale, itoa36(u->no));
-    u2 = test_create_unit(test_create_faction(0), u->region);
+    u2 = test_create_unit(test_create_faction(NULL), u->region);
     al = ally_add(&u->faction->allies, u2->faction);
     al->status = HELP_GUARD;
     set_level(u2, SK_CROSSBOW, TEACHDIFFERENCE);
@@ -666,8 +679,8 @@ static void test_teach_many_to_many(CuTest *tc) {
 
     test_setup();
     init_resources();
-    f = test_create_faction(0);
-    r = test_create_region(0, 0, 0);
+    f = test_create_faction(NULL);
+    r = test_create_region(0, 0, NULL);
     s1 = test_create_unit(f, r);
     scale_number(s1, 20);
     s1->thisorder = create_order(K_STUDY, f->locale, "CROSSBOW");
diff --git a/src/summary.test.c b/src/summary.test.c
index db0b4b7e9..6448c5e66 100644
--- a/src/summary.test.c
+++ b/src/summary.test.c
@@ -12,8 +12,8 @@ static void test_summary(CuTest * tc)
 {
     struct summary *sum;
     test_setup();
-    test_create_faction(0);
-    test_create_faction(0);
+    test_create_faction(NULL);
+    test_create_faction(NULL);
     sum = make_summary();
     report_summary(sum, sum, true);
     CuAssertIntEquals(tc, 0, remove("parteien.full"));
diff --git a/src/tests.c b/src/tests.c
index 6bf385e39..18ecdef34 100644
--- a/src/tests.c
+++ b/src/tests.c
@@ -9,6 +9,7 @@
 #include <kernel/config.h>
 #include <kernel/alliance.h>
 #include <kernel/equipment.h>
+#include <kernel/messages.h>
 #include <kernel/plane.h>
 #include <kernel/region.h>
 #include <kernel/terrain.h>
@@ -22,7 +23,6 @@
 #include <kernel/spell.h>
 #include <kernel/spellbook.h>
 #include <kernel/terrain.h>
-#include <kernel/messages.h>
 #include <util/functions.h>
 #include <util/language.h>
 #include <util/lists.h>
@@ -231,6 +231,10 @@ static void test_reset(void) {
     }
     random_source_reset();
 
+    mt_register(mt_new_va("changepasswd", "value:string", NULL));
+    mt_register(mt_new_va("starvation", "unit:unit", "region:region", "dead:int", "live:int", NULL));
+    mt_register(mt_new_va("malnourish", "unit:unit", "region:region", NULL));
+
     if (errno) {
         int error = errno;
         errno = 0;
@@ -238,9 +242,15 @@ static void test_reset(void) {
     }
 }
 
+void test_inject_messagetypes(void)
+{
+    message_handle_missing(MESSAGE_MISSING_REPLACE);
+}
+
 void test_setup_test(CuTest *tc, const char *file, int line) {
     test_log_stderr(LOG_CPERROR);
     test_reset();
+    message_handle_missing(MESSAGE_MISSING_ERROR);
     if (tc) {
         log_debug("start test: %s", tc->name);
     }
diff --git a/src/tests.h b/src/tests.h
index 61a896c3c..54764fd94 100644
--- a/src/tests.h
+++ b/src/tests.h
@@ -59,7 +59,6 @@ extern "C" {
     void test_create_castorder(struct castorder *co, struct unit *u, int level, float force, int range, struct spellparameter *par);
     struct spell * test_create_spell(void);
 
-    int RunAllTests(void);
     void test_translate_param(const struct locale *lang, param_t param, const char *text);
     const char * test_get_messagetype(const struct message *msg);
     struct message * test_find_messagetype_ex(struct message_list *msgs, const char *name, struct message *prev);
@@ -74,6 +73,7 @@ extern "C" {
     void assert_string_parameter(struct CuTest * tc, struct message *msg, int index, const char *arg);
 
     void disabled_test(void *suite, void (*)(struct CuTest *), const char *name);
+    void test_inject_messagetypes(void);
 
 #define DISABLE_TEST(SUITE, TEST) disabled_test(SUITE, TEST, #TEST)
 
diff --git a/src/travelthru.test.c b/src/travelthru.test.c
index 1a8871a74..8a38891b1 100644
--- a/src/travelthru.test.c
+++ b/src/travelthru.test.c
@@ -29,13 +29,13 @@ static void setup_travelthru(travel_fixture *fix, int nunits) {
     region *r;
     faction *f;
 
-    r = test_create_region(0, 0, 0);
+    r = test_create_region(0, 0, NULL);
     while (r->attribs) {
         a_remove(&r->attribs, r->attribs);
     }
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     while (nunits--) {
-        unit *u = test_create_unit(f, test_create_region(1, 0, 0));
+        unit *u = test_create_unit(f, test_create_region(1, 0, NULL));
         travelthru_add(r, u);
     }
     fix->r = r;
diff --git a/src/triggers/shock.test.c b/src/triggers/shock.test.c
index ca3eda432..314c877df 100644
--- a/src/triggers/shock.test.c
+++ b/src/triggers/shock.test.c
@@ -4,17 +4,24 @@
 #include <magic.h>
 #include <kernel/unit.h>
 #include <kernel/faction.h>
+
 #include <util/event.h>
+#include <util/message.h>
 
 #include <tests.h>
 #include <CuTest.h>
 
+static void shock_setup(void) {
+    mt_register(mt_new_va("shock", "mage:unit", "reason:string", NULL));
+}
+
 static void test_shock(CuTest *tc) {
     unit *u;
     trigger *tt;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    shock_setup();
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     create_mage(u, M_GRAY);
     set_level(u, SK_MAGIC, 5);
     set_spellpoints(u, 10);
@@ -34,7 +41,8 @@ static void test_shock_low(CuTest *tc) {
     trigger *tt;
 
     test_setup();
-    u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
+    shock_setup();
+    u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
     create_mage(u, M_GRAY);
     set_level(u, SK_MAGIC, 5);
     set_spellpoints(u, 1);
diff --git a/src/util/log.c b/src/util/log.c
index bae1556ed..51479cb4a 100644
--- a/src/util/log.c
+++ b/src/util/log.c
@@ -222,7 +222,6 @@ static void log_write(int flags, const char *module, const char *format, va_list
     }
 }
 
-
 void log_fatal(const char *format, ...)
 {
     va_list args;
diff --git a/src/util/message.c b/src/util/message.c
index a080ff7a6..a919f5f7d 100644
--- a/src/util/message.c
+++ b/src/util/message.c
@@ -127,6 +127,7 @@ message_type *mt_new_va(const char *name, ...)
             break;
     }
     va_end(marker);
+    args[i] = 0;
     return mt_new(name, args);
 }
 
@@ -243,7 +244,7 @@ void msg_free(message * msg)
 
 void msg_release(struct message *msg)
 {
-    assert(msg->refcount > 0);
+    assert(msg && msg->refcount > 0);
     if (--msg->refcount > 0)
         return;
     msg_free(msg);
@@ -251,7 +252,7 @@ void msg_release(struct message *msg)
 
 struct message *msg_addref(struct message *msg)
 {
-    assert(msg->refcount > 0);
+    assert(msg && msg->refcount > 0);
     ++msg->refcount;
     return msg;
 }
diff --git a/src/volcano.test.c b/src/volcano.test.c
index 77c5b2fcb..bc2aa2165 100644
--- a/src/volcano.test.c
+++ b/src/volcano.test.c
@@ -20,7 +20,7 @@ static void test_volcano_update(CuTest *tc) {
     const struct terrain_type *t_volcano, *t_active;
     
     test_setup();
-    mt_register(mt_new_va("volcanostopsmoke", "region:region", 0));
+    mt_register(mt_new_va("volcanostopsmoke", "region:region", NULL));
     t_volcano = test_create_terrain("volcano", LAND_REGION);
     t_active = test_create_terrain("activevolcano", LAND_REGION);
     r = test_create_region(0, 0, t_active);
@@ -42,14 +42,14 @@ static void test_volcano_outbreak(CuTest *tc) {
     const struct terrain_type *t_volcano, *t_active;
     
     test_setup();
-    mt_register(mt_new_va("volcanooutbreak", "regionv:region", "regionn:region", 0));
-    mt_register(mt_new_va("volcanooutbreaknn", "region:region", 0));
-    mt_register(mt_new_va("volcano_dead", "unit:unit", "region:region", "dead:int", 0));
+    mt_register(mt_new_va("volcanooutbreak", "regionv:region", "regionn:region", NULL));
+    mt_register(mt_new_va("volcanooutbreaknn", "region:region", NULL));
+    mt_register(mt_new_va("volcano_dead", "unit:unit", "region:region", "dead:int", NULL));
     t_volcano = test_create_terrain("volcano", LAND_REGION);
     t_active = test_create_terrain("activevolcano", LAND_REGION);
     r = test_create_region(0, 0, t_active);
     rn = test_create_region(1, 0, t_volcano);
-    f = test_create_faction(0);
+    f = test_create_faction(NULL);
     u1 = test_create_unit(f, r);
     u1->hp = u1->number;
     u2 = test_create_unit(f, rn);
diff --git a/src/wormhole.test.c b/src/wormhole.test.c
index 3de0292ff..eafa86572 100644
--- a/src/wormhole.test.c
+++ b/src/wormhole.test.c
@@ -9,6 +9,7 @@
 #include <kernel/terrain.h>
 
 #include <util/attrib.h>
+#include <util/message.h>
 
 #include <selist.h>
 
@@ -17,12 +18,20 @@
 void sort_wormhole_regions(selist *rlist, region **match, int count);
 void make_wormholes(region **match, int count, const building_type *bt_wormhole);
 
+static void setup_wormholes(void) {
+    mt_register(mt_new_va("wormhole_appear", "region:region", NULL));
+    mt_register(mt_new_va("wormhole_dissolve", "region:region", NULL));
+    mt_register(mt_new_va("wormhole_exit", "unit:unit", "region:region", NULL));
+    mt_register(mt_new_va("wormhole_requirements", "unit:unit", "region:region", NULL));
+}
+
 static void test_make_wormholes(CuTest *tc) {
     region *r1, *r2, *match[2];
     terrain_type *t_plain;
     building_type *btype;
 
     test_setup();
+    setup_wormholes();
     t_plain = test_create_terrain("plain", LAND_REGION);
     btype = test_create_buildingtype("wormhole");
     match[0] = r1 = test_create_region(0, 0, t_plain);
@@ -45,6 +54,7 @@ static void test_sort_wormhole_regions(CuTest *tc) {
     selist *rlist = 0;
 
     test_setup();
+    setup_wormholes();
     t_plain = test_create_terrain("plain", LAND_REGION);
     r1 = test_create_region(0, 0, t_plain);
     r2 = test_create_region(1, 0, t_plain);