Bugfix and More tests for plugin logic