added tests, fixed many bugs
Merge pull request #15 from Ragzouken/master

added tests, fixed many bugs