Properly encode IMPLICIT tag

Add tests for IMPLICIT and EXPLICIT tags with submodel and fix broken code.
Hm... I think I'll need to refresh my memory on this :) I don't get it right now.