Fix failures in test_treelength_1 and test_treelength_1_thread_2