Generic error handling

@bschmoker identified and fixed a couple of issues that popped up when calling `to_obj()` on an empty `GenericTestMechanism` and `YaraTestMechanism` instance.

Resolves #227