some minor tweaks and improvements and test fix