Remove old code and add some tests
Add function to write the objects
Update the factory