Minor code improvements

Hi,

I really liked the project. So I start digging into the code. While doing this I noticed several place where the code could be improved.

This pull request doesn't alter the functionality, as far as I can tell. I removed some and simplified (in my opinion) some part of the codebase. Also I added a missing test case.

p.s. The code will even be a bit faster. In my machine the `master` is roughly:

```
PhantomJS 1.9.7 (Mac OS X): Executed 38 of 38 SUCCESS (1.077 secs / 0.964 secs)
grunt karma:unit  3.64s user 0.55s system 83% cpu 4.988 total
```

With the changes:

```
PhantomJS 1.9.7 (Mac OS X): Executed 39 of 39 SUCCESS (0.978 secs / 0.869 secs)
grunt karma:unit  3.48s user 0.44s system 95% cpu 4.126 total
```