Remove duplicate tests

+ return empty byte-arrays instead of null

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>
Refactored Connection (some duplicate lines)

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>
Fix exception handling

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>
Add missing curly braces

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>