Added unit tests for the api controller.  Minor refactoring.
Merge pull request #45 from cloudspace/63985220_controller_tests

Added unit tests for the api controller.  Minor refactoring.