Fixed several bugs. Uncommented test_to_finish function.