diff --git a/src/frame/frame_base.cpp b/src/frame/frame_base.cpp
index 37d710952bbd4084a243feae72ab1cf7b71845ad..db17da69920a4ad27915bb3ddf27e84493504126 100644
--- a/src/frame/frame_base.cpp
+++ b/src/frame/frame_base.cpp
@@ -321,7 +321,7 @@ void FrameBase::setProblem(ProblemPtr _problem)
 
     NodeBase::setProblem(_problem);
     if (this->isKey())
-        registerNewStateBlocks(getProblem());
+        registerNewStateBlocks(_problem);
 
     for (auto cap : capture_list_)
         cap->setProblem(_problem);
diff --git a/test/gtest_has_state_blocks.cpp b/test/gtest_has_state_blocks.cpp
index 4118f0f4ddc7753a0d7b8c513b9733f0d1c3beff..d8b46e9b721fa4f9947138eee2655ed3ad25bff0 100644
--- a/test/gtest_has_state_blocks.cpp
+++ b/test/gtest_has_state_blocks.cpp
@@ -50,7 +50,7 @@ class HasStateBlocksTest : public testing::Test
 };
 
 
-TEST_F(HasStateBlocksTest, Notifications_setKey)
+TEST_F(HasStateBlocksTest, Notifications_setKey_add)
 {
     Notification n;
     ASSERT_FALSE(problem->getStateBlockNotification(sbp0, n));
@@ -65,7 +65,7 @@ TEST_F(HasStateBlocksTest, Notifications_setKey)
     ASSERT_EQ(n, ADD);
 }
 
-TEST_F(HasStateBlocksTest, Notifications_addStateBlock)
+TEST_F(HasStateBlocksTest, Notifications_add_makeKF)
 {
     Notification n;
 
@@ -91,15 +91,24 @@ TEST_F(HasStateBlocksTest, Notifications_addStateBlock)
     ASSERT_TRUE(problem->getStateBlockNotification(sbv0, n));
     ASSERT_EQ(n, ADD);
 
+}
+
+TEST_F(HasStateBlocksTest, Notifications_makeKF_add)
+{
+    Notification n;
+
     // first make KF, then add SB
 
     F1->link(problem->getTrajectory());
+    F1->setKey();
 
     F1->addStateBlock("P", sbp1);
 
-    F1->setKey();
-
     ASSERT_TRUE(problem->getStateBlockNotification(sbp1, n));
+    ASSERT_EQ(n, ADD);
+
+    // add another SB
+
     ASSERT_FALSE(problem->getStateBlockNotification(sbv1, n));
 
     F1->addStateBlock("V", sbv1);