Added logic to serialize Error objects correctly

This should fix #97.
Fixed unit tests, now with regexes.
Merge pull request #158 from emilecantin/master

Added logic to serialize Error objects correctly