Update String code for Java 7 compatibility.

Scalang uses unsafe operations to avoid String copies. This adds a unit
test for term decoding and fixes a bug when using scalang with Java 7.