elementfactory: fix factory leak in test