Fix some issue found thanks to phpspec, also fixed some CS
Merge pull request #583 from stloyd/bugfix/issues_and_cs

Fix some issue found thanks to phpspec, also fixed some CS