update core.py and add tests