Fix 1.13.5 regressions

This branch fix: 
  https://bugs.launchpad.net/oq-platform/+bug/1236342
  https://bugs.launchpad.net/oq-platform/+bug/1236345