Refactored solution 002, added tests, cleaned code.