The "handin" plug-in is a facility to check that a player gives the proper items, and consume them if it is the case. It should really be used as the last check in an "if" chain, as it performs a side-effect (removes the given items, they are given it is too late).
So you can probably avoid having the player "loose" the items by first checking for your max_level (and anything else), then when all conditions are fulfilled perform the hand-in. Basically you check that the PC fulfills the conditions for the hand-in, then you have the NPC accept the items. "accept-and-eat" would be a good description for the "handin".
Another solution you have is to re-summon the given items in case you use "handin" first (gulp the items are eaten, only use with troll NPCs

). Add a summonitem instruction with the item ID and 4 occurences. The "return_items" plugin does just that.
Or if you want to make tests on the items given by the player before doing other tests (may be in some case you would like to), you can always return to the definition of the "handin" and use the "$itemcount" map, which associates given item IDs to the amount of items given. Remeber to check that an item has been given before checking its amount. You can even adjust the amount given as you want, in the same way "handin" works.
For example you could use (from a silly quest I have been writing) :
Code:
if(defined($itemcount{13078}) && $itemcount{13078} >= 4 # Summoned: Black Bread)
{
$itemcount{13078} = $itemcount{13078} - 4; # Summoned: Black Bread
if($itemcount{13078} == 0)
{ delete $itemcount{13078}; }
quest::say("Groumph ! It fuud, but not guud. Belux said me eat dat ? OK me eat. Me not want Glob froglok.");
I hope this clears out how "handin" works. In fact it is a quite small function, worth reading for sure.