Solution: You have to use -NoCommit flag when creating the activity (just put it right at the end of the creation string). It will be commited on relationship object creation time and the script will work just fine.
This is due to fact that activities use Membership relationship type and have to be commited together with relationship object. Otherwise they get "related" to themselves and refuse to relate to other objects.
If you need more details: http://blogs.msdn.com/b/scplat/archive/2010/04/02/overview-of-relationship-types-in-the-system-center-platform.aspx