diff --git a/main.cpp b/main.cpp
index 9ad116b0d8a2d06624e64f3c5683190e4d942dbe..b0e32dc5b3018af31568551b891abece4608c8ca 100644
--- a/main.cpp
+++ b/main.cpp
@@ -221,23 +221,21 @@ TEST(cell_tree, balance) {
     }
 }
 
-void test_json() {
+// this test doesn't test anything yet... it just loads each cell in turn
+// from a json file and creates a .dot file for it
+TEST(cell_tree, json_load) {
     json  cell_data;
     std::ifstream("cells_small.json") >> cell_data;
 
     for(auto c : range(0,cell_data.size())) {
         std::vector<int> parent_index = cell_data[c]["parent_index"];
         cell_tree tree(parent_index);
-        std::cout << "cell " << c << " ";
-        //tree.balance();
         //tree.to_graphviz("cell_" + std::to_string(c) + ".dot");
         tree.to_graphviz("cell" + std::to_string(c) + ".dot");
-        //std::cout << memory::util::yellow("---------") << std::endl;
     }
 }
 
 int main(int argc, char **argv) {
-    test_json();
     ::testing::InitGoogleTest(&argc, argv);
     return RUN_ALL_TESTS();
 }
diff --git a/tree.hpp b/tree.hpp
index 3645042ebf3346d9df0f74911bd4217664e96a9d..a548b346c86a3910df2574956644983e4446e8c9 100644
--- a/tree.hpp
+++ b/tree.hpp
@@ -175,7 +175,7 @@ class tree {
         return sizeof(int_type)*data_.size() + sizeof(tree);
     }
 
-    tree change_root(int b) const {
+    tree change_root(int b) {
         assert(b<num_nodes());
 
         // no need to rebalance if the root node has been requested
@@ -205,6 +205,10 @@ class tree {
             new_tree.children_.begin(), [&p] (int i) {return p[i];}
         );
 
+        // copy in new data
+        // this should be done with a swap, to avoid a malloc-free, however
+        // using std::swap gives a seg fault... todo
+        data_ = new_tree.data_;
         //std::swap(data_, new_tree.data_);
 
         return new_tree;