If you want to get technical, it is the specifics which are fuzzy, not the context; the context is perfectly clear: Onan was commanded to continue his brother's line, he did not, and he was struck down by God for it. In context, it seems very clear that the disobedience is what he was punished...