test_{delete,chgrp}.py: Add tests.

This commit implements tests from tickets #12452 and #12544.
test_chgrp.py: Optimise imports.