added tests and modified js