Fixed two file-descriptor leaks

Fixes EUCA-8621