Cleaning up the code

* Fixed the UTF-8 issue
* Swapped to use the Java 7 try (resource) functionality
* Forked the test code out into src/test/java