testprogs: Add common kinit function