Testing the Rank and Definiteness of Estimated Matrices with Applications to Factor, State-Space and ARMA Models