Fixing unit tests and cleanup