Fixes to handling of boxed types

Boxed types and primitive types should cooperate properly now with
primitive types in all basic cases. Added tests that verify this.