Add functionality to library.rb and fix test scripts in library_spec.rb