Tidy up code

Delegate path to file, to simplfy some method calls
Reorder the logic for :clean to check it exisits first
Simplfy publishing logic

Remove stubbing and add in a helper and fix factory