added tests and final changes