Better error handling for Java client. Fixed error in device inheritance
hierarchy. Updated tests with new cases.