idea support, first unit test, some refactoring