added tests and fixed minor errors