- Fixed bug #917, which mis-encoded quotes (thanks to Uli Martens). - Added unit tests. - Minor unrelated edits.