Move the spa global in the worker into tkWorker

This moves the `spa` global variable into `tkWorker`. This helps encapsulation and makes it easier to write tests which I need in a future PR.