Unit tests and fixes for file descriptors and strings