Corrected file mode and added more tests