Closed STD File IO during all tests.

Closed STD File descriptors during tests so that valgrind output from
make tests command won't be so verbose.
Merge branch 'close-stdio'