BAC-86: Add a hook to check if uploaded image file is corrupted

Add unit tests