more strict checks and reseting state
Merge pull request #3 from ilya-lavrenov/test

more strict checks and reseting state