added unit test, removed some unused code