Added new API for unit testing; Added basic tests.