socket api tweaks and added tests