Finished input parsing logic, added some tests