Fix as_string() (RT bug #49632)

This is a shorter patch than what was proposed on RT, and I've included a test to verify that it works.

https://rt.cpan.org/Public/Bug/Display.html?id=49632