Fixed code with tests. Also trying formatting for readme.