fixed final last missing tests and cleaned up plugin code