Added tests and some functions