Fixed plugin load bug.

Fixed bug with plugin files not being closed.
Slightly modified some tests.