Added unit tests
fixed minor errors in tests
Writing files in utf-8 instead of latin-1