added unit tests for each function and update to models.py Fixes #4