"Than I realized" is correct for two reasons:
1. You need the conjunction "than" to link the two ideas. It means the same as "when" and indicates that one action had just been completed when a second action started.
2. You need the past perfect in the first clause, but the past simple in the second. The past perfect indicates an action one step further back in the past than the action described in the second clause.
In the second question, you need the past perfect, not the present perfect. The present perfect indicates a connection between the past and the present: "I've gone out to do some shopping" implies "I am not at home." The present perfect describes a present set of circumstances.
However, the first sentence is in the simple past, and this indicates quite clearly that we are talking about a past set of circumstances. The past perfect in the next sentence makes a connection between the past and the more distant past: "I was not at home when you called". (It's possible I returned later, but at the time I was not there.)
We can explain this diagrammatically, like this:
Code:----------(NOW)----------> | | A----->B He has gone shopping. He's not in. A: He went shopping B: He is not in ----------(NOW)----------> | | A--->B He had gone shopping when we called A: He went shopping B: We called, and he was out




