added test + code cleanup