Finally got tests to pass. Did some refactoring and adding comments. Sorry that was vague.