fix for MID-1749 + MID-1731.
Merge branch 'master' of https://github.com/Evolveum/midpoint