Fully working HMM with JUnit tests