added unit tests for most functions