added tests and code