Fix possible double close

Signed-off-by: Sven Strickroth <email@cs-ware.de>
Merge pull request #1753 from 13ren/log-bugfix

Fix -n bug; default to all ancestors
Merge pull request #1755 from csware/double-close

Fix possible double close
Update expected result for a foreach test