Split out file write tests into test_write_recipe_file.py

Also ran pyflakes on split files and removed unnecessary imports.