Created phpUnit tests, phpDoc documentation, refactoring

Hey, here's the refactored code I wrote!