Testing underidentification in linear models, with applications to dynamic panel and asset pricing models