added test + small refacgoring