switched to constructor and added unit tests