added unit tests and functional tests