Adding in more unit tests. Cleaned up code analysis issues.