Fixed a potential array out-of-bounds error on noise generation (thanks to Dgizusse; fixes issue #26)
Updated main sample with a test case for the array out-of-bounds error