Tried to improve the type safety a bit. Added new test that showed possible weakness that I was not aware of. Added project encoding to pom.xml