Added checks for edge cases, completed unit tests
Chose some more clear variable names, added a few comments
Added check for minimum peak separation