Fix file descriptor leaks
Merge branch 'testing' into fix/fd-leak
Merge pull request #534 from nyuszika7h/fix/fd-leak

Fix file descriptor leaks
Fix previous merge.
Fix previous merge (again).