added library functionality, the first rspec test and fixed a bug