Added tests and more functionality