Perror formatting fix

This fix improves the formatting of the perror function and also includes a simple test case
which tests the error message when opening a non existing file.