Added RSpec tests. Cleaned up code using Rubocop.