Refactor task into an inner class

This is so it can be treated as an immutable piece of work without any
dependencies that have to be injected - my original idea was horrible.