Fix PEP8 errors.
Factor script_name calculating out into a class method so it can be easily tested.