Fix EZP-21662: The JS REST client's CAPIError Class major refactoring

JIRA issue: https://jira.ez.no/browse/EZP-21662

New class structure implemented. Some small fixes in errors handling workflow.
Unit tests fixed accordingly.