Rewrite test.py to use pytest