Refactor and fix logic in recording api, test framework

Numerous changes were made to the internals of recording api methods to
refactor existing code or fix logic errors.
Implemented a shelve object so changes can persist more reliably and
elminate the need for server teardown code.
Testing framework now uses pytest fixtures to create a baseline for
tests instead of xunit style setup and teardown methods.
Refactored and made logic fixes to test_server.py tests.