Fix Undefined index: id
Add test