Fix bugs. NPE when testing connection in tablet