adding test files and fixing bugs: encoding and exception handling

Change-Id: I1297d207a7684b02c62b015d9789a0a391de2cc8