bugfix and regression test