added unit tests, small fixes