fix sqlalchemy's job.update() call to handle race condition

- the current query(job).update() method of sqlalchemy doesn't consider
  the version_id column introduced to handle race condition (Optimistic
Offline Lock).
- modified the update call to use session.add(job) & session.flush(job)
  so that sqlalchemy can use the optimistic offline lock feature using
job table's version id column.
- added test to ensure the version_id column is used as expected.
- fixed a minor pep8 issue on test_jobs