add a test to test a job's lifecycle.
Fix handling of close events.
Move `save job` functionality of pulsar.createJob to a separate method pulsar._saveJob.