global refactoring. resolves #2
some tests :) resolves #4