Added tests and code for tests