Fix file io exceptions and race conditions in api.py
Merge pull request #38 from umzegher/openfilelocked

Updates to api.py
Set up initial unit test infrastructure.
Excluded all *.p files from commits.
Added 2 back into shebang on setup.py
Minor change to resolve conflict.