core/tests.py and samples/tests.py code cleanup