Core: Fix support for multiple error classes

String#replace with a string argument replaces just once, not all matches.

Closes gh-884