code cleanup and extra tests