adding UT and fixing file writer to comply