changed the decode method to prevent potential nullpointer exception and added finally to close connection
updated test class to remove some more redundant variables