Model event code improved and its tests