Fix duplicate files and write more tests