Upper bound for lifespan of solutions to certain semilinear parabolic, dispersive and hyperbolic equations via a unified test function method