fix analyze method, improve test coverage