(refactor) simplified content_type retrieval

This commit changes the content_type retrieval
to use the built in method `extension` that is
provided on the Path.

It also adds a test.
Thanks! I didn't know these exist. I'll change that and force push the PR.