Add tests for emit_assembly and emit_memory
Fix memory leak in emit_assembly / emit_object