bugfix + tests