updated test and fn's to remove duplicate code