Ticket_6: fixed almost all.
Ticket_6: fixed almost all.
Ticket_6: added test, but it doesnt work.