Improve import logic to reconstruct facts and thus correctly apply all relations

Add a test for it.