Check and handle null cases for getMimeTypeForFile() #271

Also created unit test.
Merge branch 'refs/heads/#271'