added tests and fixed #14