code cleanup and finalization of tests