bugfix and minor change to unit tests