Fixed settings test and pages calculation moved from forEach statement