Estimation and testing nonhomogeneity of Hidden Markov model with application in financial time series