refactored code to make it testable
refactored code to make it testable


Former-commit-id: 9a7d9b8b8ff1cc11b76a80a029ce5a90803ed92a [formerly 698cb9bff9587a7bf1098fd72c5c8dd7646f82a4] [formerly 698cb9bff9587a7bf1098fd72c5c8dd7646f82a4 [formerly 94c7d4e6c299be688940321c7d6459e0e8cf93a9]]
Former-commit-id: 5423670063fc6c369b34e6e08593c07a62f4e210
Former-commit-id: e632383940eb7ea9423eb048ec9ead6f0b345dc4
gem/oq-engine,gem/oq-engine,gem/oq-engine,gem/oq-engine,gem/oq-engine