Fix vulnerability functions

Addresses:
- https://bugs.launchpad.net/openquake/+bug/1160840
- https://bugs.launchpad.net/openquake/+bug/1160844