Moved ErrorTests to ReferenceTests, fixed error handling

Also fixed some other tests. All tests work again.
Conversion to CmdletInvocationException from simply thrown exceptions