Added tests for encode - bugs in data persist.
Fixed all reported bugs, added tests and ready to upload to CPAN.