Fixed a bug and written some additional Jasmine specs.