Add test cases for Docker image name parsing and cleanup

The tests for Docker image name parsing are repetitive and do not
cover enough test cases.

Refactor the tests to use table testing and add additional test cases.