Minor bugfixes. Add plugin tests