Bugfix and test