fixed leaking local variable
fixed tests for flags task