Bugfix and add test