Fix within function and add specs for it. Resolves #47
Fix nearby function and add specs for it. Resolves #47