bugfixes
refactoring
more tests