Refactored indirect codec and added recursive tests