TST fix file descriptor leak and a bad variable name in get_testlog