Electronic structure of H2 and HeH+ computed directly in momentum space