refactor ionic.tap and start writing tests