1.fixed bugs in database updates in AddCase Function
2. added main function for unit testing