Fixed connection problems + testing connection function