Added callback, test and improved the connect().