Fixed some file problems
Added tests