Made test function more generic