Removed closing plugapi in test to allow for additional command testing.
Updated test and removed closing of plugapi.
Added condition check on key variable.