A modified test function method for damped waves