Add more unit tests and split functional tests