big work with tests, some rewriting...