fix socket reconnect bug, add more tests