engine:

Refactored `run_calc` to make it easier to test.
tests/engine_test:

Added some tests to exercise the logic in `engine.run_calc`.

It was completely missing tests before.
Merge pull request #1257 from larsbutler/read-logic-trees-from-db

Reading logic trees from DB - follow up (fix for a careless refactoring error).

[r=micheles,matley] [f=*trivial]
Merge branch 'master' of github.com:gem/oq-engine into streaming-xml-writer