Fix exception in prepare_tests