Hey Man,
I have the same problem. I had my testsoterone levels checked a couple of years ago and was told they were 14 (I think that is "normal" but on the lower end). I can get an OK erection when masturbating but if I don't touch it for a few seconds it goes soft (I find keeping it hard lying down near impossible). I have found that I lose it during sex a lot too.
Testosterone could certainly be the issue. You may have been having a "good day" when it was checked, as your levels can very a lot even throughout the day. It would probably be a good idea to see your physician again about it.
Usually (but not always) morning erections and getting hard while masturbating means that physiologicly, things are working, It sounds like you're not quite at that point, particularly if it's impossible for you to keep it hard laying down, when you're working against gravity. I'd say go see your physician.