added tests and changed repository to use JPA API instead of Hibernate