Add basic tests for FeatureDetection functions.

Also clean up logic in the methods a bit, and fix JSHint.