The meanings of 不好意思 In response to kindnesses I sometimes say "不好意思了" and I don't think there has ever been a misunderstanding.  But as an English speaker I feel unsure how this is different from saying "不好意思" for a bad thing.  Can anyone advise on how the two meaning differ in use?

Does 了 occur here only in response to a kindness, and not in describing a bad thing?

Let me give an example.  A friend took me to see a friend of hers who gave me a thoughtful gift.  I said "thank you."  Everyone involved spoke enough English but later I thought "thank you" was not the right thing to say.  In English I could have said "this is too kind of you," or in Mandarin 不好意思了.  My friend confirmed that in her opinion those would have been better.  And I normally do say 不好意思了 at times like this. 

It was not a case of any problem either with the gift or my gratitude.  It was just a case where I should have been more modest.  Maybe such things are always clear from context but I wonder if there are points of usage aside from context to distinguish the agreeable sense of 不好意思 from the sense of something wrong.
不好意思 has two meanings which are quite similar but applied differently. Quoting from 汉典 (English translation mine): 


  ①表示碍于情面而只能怎样或不便怎样。(to indicate a face-saving compromise)


This is usually used as a form of acknowledgement and indirect acceptance of another person's kindness or generosity when none is expected. The person saying it usually has little choice, either because he is in desperate need for help or it would make the situation embarrassing if he refuses the generosity.


  ②害羞；难为情。(feel shy or embarrassed about the situation)


This is used in situations where one would feel embarrassed for troubling someone else. The level of embarrassment can be quite abysmal though, especially when spoken in sarcasm or when used for very minor things like asking for directions.


  Does 了 occur here only in response to a kindness, and not in
  describing a bad thing?


To answer your question, 了, does not determine the meaning of 不好意思. The reason why you may think so is due to the way you apply the first meaning of 不好意思 at the end of a sentence. Some examples to demonstrate why this is not necessarily the case:


真不好意思，又让您破费了。(without 了 ①)
不好意思，厕所在哪里？(asking for directions ②)
她被夸得不好意思了。(counter example ②)
不好意思了大家，我已经上岸了，你们继续摸石头吧。(counter example with sarcasm ②)