added unit tests and misc