Working file again... almost shit my pants.
Added test cases.