Gsim validation

Improved the validation of GSIM strings (see https://bugs.launchpad.net/oq-engine/+bug/1401760) and some refactoring. The tests are green: https://ci.openquake.org/job/zdevel_oq-risklib/132/