diff --git a/procedures/insertEntity.sql b/procedures/insertEntity.sql
index b3b271ead8ac01b5141412b720422baa00ec26e3..be4f77d8bb013424192582015b7710f9b7cdae2e 100644
--- a/procedures/insertEntity.sql
+++ b/procedures/insertEntity.sql
@@ -45,7 +45,7 @@ BEGIN
     DECLARE NewEntityID INT UNSIGNED DEFAULT NULL;
     DECLARE NewACLID INT UNSIGNED DEFAULT NULL;
     DECLARE Hash VARBINARY(255) DEFAULT NULL;
-    DECLARE Version VARBINARY(255) DEFAULT SHA1(UUID());
+    DECLARE Version VARBINARY(255) DEFAULT NULL;
     DECLARE Transaction VARBINARY(255) DEFAULT NULL;
 
     call entityACL(NewACLID, ACL);
@@ -54,7 +54,9 @@ BEGIN
     SET NewEntityID = LAST_INSERT_ID();
 
     IF is_feature_config("ENTITY_VERSIONING", "ENABLED") THEN
+        -- TODO this is transaction-scoped variable. Is this a good idea?
         SET Transaction = @SRID;
+        SET Version = SHA1(UUID());
         CALL insert_single_child_version(NewEntityID, Hash, Version, Null, Transaction);
     END IF;
 
diff --git a/procedures/retrieveEntityParents.sql b/procedures/retrieveEntityParents.sql
index 74c7f67fb0eb85f477fd6ccd1f0d148bc1b161eb..5bf98309ddc739eeaa1821db4c0a96f09b9fe7bb 100644
--- a/procedures/retrieveEntityParents.sql
+++ b/procedures/retrieveEntityParents.sql
@@ -85,8 +85,7 @@ retrieveEntityParentsBody: BEGIN
                 JOIN entities AS e
                 ON (i.parent = e.id)
                 WHERE i.child = EntityID
-                AND i.child_iversion = IVersion
-                AND i.rpath = EntityID;
+                AND i.child_iversion = IVersion;
 
             LEAVE retrieveEntityParentsBody;
         END IF;
diff --git a/tests/test_autotap.sql b/tests/test_autotap.sql
index b7f21cd62df68ef7757b78862854e8d571f2eaf1..2be5ec6c246aa2593fe0315c87cbea1a32cf74aa 100644
--- a/tests/test_autotap.sql
+++ b/tests/test_autotap.sql
@@ -2232,7 +2232,7 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','entity_version','entity
 SELECT tap.has_column('_caosdb_schema_unit_tests','entity_version','hash','');
 SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','entity_version','hash','varbinary(255)','');
 SELECT tap.col_extra_is('_caosdb_schema_unit_tests','entity_version','hash','','');
-SELECT tap.col_default_is('_caosdb_schema_unit_tests','entity_version','hash',NULL,'');
+SELECT tap.col_default_is('_caosdb_schema_unit_tests','entity_version','hash','NULL','');
 SELECT tap.col_charset_is('_caosdb_schema_unit_tests','entity_version','hash',NULL,'');
 SELECT tap.col_collation_is('_caosdb_schema_unit_tests','entity_version','hash',NULL,'');
 
diff --git a/tests/test_entity_versioning.sql b/tests/test_entity_versioning.sql
index 653e11e0138e465ed173bcda7feef28c9317871d..3c7c96e7c76b05f62b86cbef68f4e9399747e62b 100644
--- a/tests/test_entity_versioning.sql
+++ b/tests/test_entity_versioning.sql
@@ -10,19 +10,25 @@ CALL tap.no_plan();
 -- #####################################################################
 
 -- SETUP
-DELETE FROM entities WHERE name="EntityName";
-CALL entityACL(@ACLID1, "{acl1}");
-CALL insertEntity("EntityName", "EntityDesc", "RECORDTYPE", "{acl1}");
-SELECT id INTO @EntityID FROM entities WHERE name="EntityName";
+
+-- Disable versioning because we want to test `insert_single_child_version`
+-- separately from `insertEntity` but the former is called inside the latter
+-- when versioning is enabled.
+DELETE FROM feature_config WHERE _key = "ENTITY_VERSIONING";
 INSERT INTO transactions (srid,seconds,nanos,username,realm) VALUES 
 ("SRIDbla", 1234, 2345, "me", "home"),
 ("SRIDblub", 2345, 3465, "me", "home"),
 ("SRIDblieb", 3456, 4576, "you", "home");
+DELETE FROM entities WHERE name="EntityName";
+CALL entityACL(@ACLID1, "{acl1}");
+CALL insertEntity("EntityName", "EntityDesc", "RECORDTYPE", "{acl1}");
+SELECT id INTO @EntityID FROM entities WHERE name="EntityName";
 
 
 -- TEST insert_single_child_version
 SELECT count(*) INTO @x FROM entity_version;
 SELECT tap.eq(@x, 0, "no versions there yet");
+
 CALL insert_single_child_version(@EntityID, "hashbla", "versionbla", NULL, "SRIDbla");
 SELECT _ipparent INTO @x from entity_version WHERE version="versionbla";
 SELECT tap.eq(@x, NULL, "no parent for the first version");
@@ -33,7 +39,7 @@ SELECT tap.eq(@x, 1, "one version there yet");
 CALL insert_single_child_version(@EntityID, "hashblub", "versionblub", "versionbla", "SRIDblub");
 
 SELECT _ipparent INTO @x from entity_version WHERE version="versionblub";
-SELECT tap.eq(@x, 0, "the original entity is the parent");
+SELECT tap.eq(@x, 1, "the original entity is the parent");
 
 -- error: parent does not exist
 SELECT count(*) INTO @x FROM entity_version;
@@ -84,7 +90,7 @@ CALL insertEntityProperty(0, @EntityID, 17, "null_data", NULL, NULL,
 SELECT count(*) INTO @x FROM entity_version WHERE entity_id = @EntityID;
 SELECT tap.eq(@x, 1, "after insertEntity, a version is there.");
 SELECT _iversion INTO @x FROM entity_version WHERE entity_id = @EntityID and _ipparent is NULL;
-SELECT tap.eq(@x, 0, "after insertEntity, the _iversion number is 0.");
+SELECT tap.eq(@x, 1, "after insertEntity, the _iversion number is 1.");
 
 SELECT _ipparent INTO @x from entity_version WHERE entity_id = @EntityID;
 SELECT tap.eq(@x, NULL, "no parent for the freshly inserted entity");
@@ -99,10 +105,10 @@ CALL updateEntity(@EntityID, "NewEntityName", "NewEntityDesc", "RECORD", NULL, N
 SELECT count(*) INTO @x FROM entity_version WHERE entity_id = @EntityID;
 SELECT tap.eq(@x, 2, "after updateEntity, a second version is there.");
 
-SELECT _iversion INTO @x FROM entity_version WHERE entity_id = @EntityID and _ipparent = 0;
-SELECT tap.eq(@x, 1, "after updateEntity, the _iversion number incremented.");
-SELECT _ipparent INTO @x FROM entity_version WHERE entity_id = @EntityID and _ipparent = 0;
-SELECT tap.eq(@x, 0, "after updateEntity, the _pparent points to the first version");
+SELECT _iversion INTO @x FROM entity_version WHERE entity_id = @EntityID and _ipparent = 1;
+SELECT tap.eq(@x, 2, "after updateEntity, the _iversion number incremented.");
+SELECT _ipparent INTO @x FROM entity_version WHERE entity_id = @EntityID and _ipparent = 1;
+SELECT tap.eq(@x, 1, "after updateEntity, the _pparent points to the first version");
 
 SELECT tap.eq(count(*), 1, "after updateEntity, one entity in archive_entities")
     FROM archive_entities;
@@ -112,7 +118,7 @@ SELECT tap.eq(count(*), 1, "after updateEntity, one entity in archive_entities")
 
 SELECT version INTO @x FROM entity_version
     WHERE entity_id = @EntityID
-    AND _iversion = 0;
+    AND _iversion = 2;
 CALL retrieveEntity(@EntityID, NULL);
 CALL retrieveEntity(@EntityID, "non-existing-version");
 CALL retrieveEntity(@EntityID, get_head_version(@EntityID));
@@ -146,11 +152,11 @@ CALL updateEntity(@EntityID, "EntityName", "EntityDesc", "RECORDTYPE", NULL, NUL
 SELECT count(*) INTO @x FROM entity_version WHERE entity_id = @EntityID;
 SELECT tap.eq(@x, 3, "after 2nd updateEntity, a 3rd version is there.");
 
-SELECT _iversion INTO @x FROM entity_version WHERE entity_id = @EntityID and _ipparent = 1;
-SELECT tap.eq(@x, 2, "after 2nd updateEntity, the _iversion number incremented again.");
-SELECT _ipparent INTO @x FROM entity_version WHERE entity_id = @EntityID and _ipparent = 1;
-SELECT tap.eq(@x, 1, "after 2nd updateEntity, the _pparent points to the 2nd version");
-SELECT tap.eq("SRIDblieb", srid, "correct transaction was stored") FROM entity_version WHERE entity_id = @EntityID AND _ipparent = 1;
+SELECT _iversion INTO @x FROM entity_version WHERE entity_id = @EntityID and _ipparent = 2;
+SELECT tap.eq(@x, 3, "after 2nd updateEntity, the _iversion number incremented again.");
+SELECT _ipparent INTO @x FROM entity_version WHERE entity_id = @EntityID and _iversion = 3;
+SELECT tap.eq(@x, 2, "after 2nd updateEntity, the _pparent points to the 2nd version");
+SELECT tap.eq("SRIDblieb", srid, "correct transaction was stored") FROM entity_version WHERE entity_id = @EntityID AND _ipparent = 2;
 
 
 -- TEST deleteEntity - should remove all versions
@@ -161,9 +167,6 @@ SELECT tap.eq(@x, 0, "no versions there any more");
 
 CALL deleteEntity(@ParentID);
 
--- TEARDOWN
-
-DELETE FROM feature_config WHERE _key = "ENTITY_VERSIONING";
 
 
 CALL tap.finish();
diff --git a/tests/test_insert_update_delete.sql b/tests/test_insert_update_delete.sql
index 7a8dc38ab0059b931d4215fdbbc344d8db5c7aed..8da6bfc187d5bcb562d68d2f079715ddb1ba288e 100644
--- a/tests/test_insert_update_delete.sql
+++ b/tests/test_insert_update_delete.sql
@@ -4,6 +4,9 @@ CALL tap.no_plan();
 
 -- SETUP
 
+-- Disable versioning and only test the non-versioning behavior
+DELETE FROM feature_config WHERE _key = "ENTITY_VERSIONING";
+
 CALL entityACL(@ACLID1, "{acl1}");
 CALL entityACL(@ACLID2, "{acl2}");
 SELECT id into @TextDatatypeID FROM entities WHERE name ="TEXT" and role="DATATYPE";