test-lib: Introduce test_chmod and use it instead of update-index --chmod