changed call to apply ... fixed tests