Write objet to file, tests