minor tweaks and test function added