bugfix and extra tests