added unit tests, stabilized code base