bugfix and add test