Move write_experiment_file to experiment.py. Add tests