Handle unicode error in json serialize properly.
Actually use pytest.raises in test.