Added unit test for convert_to_file, using a BytesIO stream to mimic a file