Additional unit tests and fixes according to unit tests. Still need to add unit tests when there are exceptions