Fixing #4213 arrayIndexThenCheck and adding tests

https://sourceforge.net/apps/trac/cppcheck/ticket/4213

Please comment if anything's too vague