PyModule_GetDict not adding custom functions and globals to the generated dictionary (Python27)

I've followed all of the basic steps trying to get a python module loaded in c++, however it seems that when I try to get the dictionary of items in the script, it ignores my functions and globals that I wanted to use inside. when I iterate through the items, all I get are the builtins, file, package, path, name, and doc attributes of the script, and nothing else. I checked __name__ and it is coming up correctly ("test.py" is my py file's name and it returns "test" just fine). When I actually try to load my functions or globals (test, qa), the PyDict_GetItemString function returns NULL. What have I done wrong such that in tutorials this works fine, but in my test application, it doesn't work?

here is my Py script, maybe I've forgotten to do something that would allow my items to be seen?

qa = "hello test"

def test(a):
    q = "hello world, I am " + a
    #print q
    return q

here is my C++ code as well, maybe I've forgotten something here?

#include <iostream>
#include <Python.h>

int main() {
    Py_Initialize();
    PyObject
        *pName,
        *pModule,
        *pDict,
        *pFunc,
        *pArgs,
        *pValue;
    // get filename as a pystring
    pName = PyString_FromString("test");
    std::cout << std::endl << pName;
    // Import module from filename
    pModule = PyImport_Import(pName);
    std::cout << std::endl << pModule;
    // build the module's dict
    pDict = PyModule_GetDict(pModule);
    std::cout << std::endl << pDict << " " << PyDict_Size(pDict);
    PyObject* keys = PyDict_Keys(pDict);
    int s = PyList_Size(keys);
    for (int i = 0; i < s; ++i) {
        PyObject* item = PyList_GetItem(keys, i);
        printf("\n");
        printf(PyString_AsString(item));
    }

    PyObject* testvar = PyDict_GetItemString(pDict, "qa");
    printf(PyString_AsString(testvar));

    // get a function from the dict
    pFunc = PyDict_GetItemString(pDict, "test");
    std::cout << std::endl << pFunc;
    // build the arg tuple
    pArgs = PyTuple_New(1);
    // create an argument
    pValue = PyString_FromString("cee programme");
    // set an argument
    PyTuple_SetItem(pArgs, 0, pValue);
    // call the function with the func and the args
    PyObject* pResult = PyObject_CallObject(pFunc, pArgs);
    // error checking
    if (pResult == NULL) {
        printf("\nis broek");
    }

    char* res = PyString_AsString(pResult);
    // "destroy the interpreter"
    Py_Finalize();
    printf(res);

    return 0;
}