some bugfixes for the case integrity script
Merge pull request #2444 from dimagi/script-fix

some bugfixes for the case integrity script