Implement clean up json error messages

Implement testable method to clean up the weird json error messages
since they are unusable for some scopes like unmanaged-files.

Supersedes #181